说明
有时需要通过maven引入本地jar,本地运行时没有问题,打包成应用jar时出现ClassNotFound异常
通过排查发现本地引入的jar,实际并没有打包到应用jar里
方案
引入本地Jar
<dependency>
<groupId>XXXClient</groupId>
<artifactId>XXXClient</artifactId>
<version>1.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/XXXClient.jar</systemPath>
</dependency>
为spring-boot-maven-plugin设置includeSystemScope为true
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>false</executable>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>