问题描述
springboot项目开发中maven引入本地第三方jar包,在idea中运行正常。部署打成jar包后,运行报错缺少引入的jar包类
项目说明:
项目基于springboot分模块开发,在业务模块引入第三方jar
<dependency>
<groupId>com.zyb</groupId>
<artifactId>xxx-xx</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/libs/xxx-xx-1.0.jar</systemPath>
</dependency>
在springboot主入口模块的pom中,maven-plugin插件配置如下
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
<configuration>
<includeSystemScope>true</includeSystemScope> <!-- 引入外部jar包 -->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
左看右看 <includeSystemScope>true</includeSystemScope>也引入了,
但项目打包部署jar运行就显示缺少外部jar中的类
原因及解决方法
springboot的maven打包插件,只会扫描当前模块下的路径,导致并不会把其他模块项目路径下的外 部jar进行打包,
将引入外部jar包的pom依赖,在主入口模块的pom中也引入一份,同时将外部的jar放到相对应的指定目录下即可解决