在springboot 2.5.14
中通过以下代码引入本地jar包:
<dependency>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/lib/test.jar</systemPath>
</dependency>
在将项目打成jar包运行时,一直报这个错误:
org.springframework.beans.factory.UnsatisfiedDependencyException。。。
caused by: ClassNotFoundException: com.text.xxx
根因是因为在maven中scope为system的依赖项在构建时默认不会被打包到项目中,所以需要增加额外配置:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
到这一步就完美解决问题了。