问题描述
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放到相对应的指定目录下即可解决
文章讲述了在Springboot项目开发中,通过maven引入本地第三方jar包,在IDEA中运行正常,但打包成jar运行时出现缺少jar包类的错误。问题在于spring-boot-maven-plugin插件在打包时不会包含系统路径下的jar。解决方案是将依赖的外部jar包复制到主入口模块并添加相应pom依赖,确保打包时一并包含。
4395

被折叠的 条评论
为什么被折叠?



