最近有需求引入阿里的第三方jar包,因为公司没有自己的maven仓库,所以放在了项目的 resources 的目录下
注意, <groupId>
、<artifactId>
、<version>
随意填写。<scope>system</scope>
必须要加,这表示导入本地的jar包。 ${project.basedir}
为项目的根路径
引入之后,本地运行没有问题,但是达成jar包运行的时候,会报找不到相关类的错误 ClassNofFoundException
排查后发现需要在springboot的maven插件中加一条配置
<includeSystemScope>true</includeSystemScope>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<!-- 打包引入第三方jar-->
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugins>
这样,下面重新打包运行就没有问题了