1. 修改POM的build标签
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 允许引入外部jar-->
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
<resources>
<!-- 打包src同目录下的lib内的jar-->
<resource>
<directory>lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<!--打包resources目录下全部文件-->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</resources>
</build>
2. 添加一个依赖
<!--自定义maven依赖-->
<dependency>
<!--随意,建议统一用自己公司域名-->
<groupId>com.coldsmog</groupId>
<!--随意,建议与jar包同名-->
<artifactId>apiclient-api</artifactId>
<version>1.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/apiclient.jar</systemPath>
</dependency>
3. 新建一个与src同级的lib目录,将jar包放入,IDEA本地开发需要额外设置成Resource属性
springboot 添加外部jar