不想将第三方自定义jar导入maven库,想直接lib引入。网上找了好多,好多方法都说了一半,东拼西凑解决,记录分享一下。
pom.xml配置文件
网上好多博客写了这里,但是我本地尝试导入后编译不报错,把工程打出来运行报noClassDefFound错误,运行时找不到包。
<!-- 引入本地jar包,编译不报错 -->
<dependency>
<groupId>com.abc</groupId>
<artifactId>abc</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/abc-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>
重要的是这里
指定maven打包时候引用的本地包的scope。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 将本地导入jar包打入生成的程序包中 -->
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
这样就可以将导入的本地jar包打入生成的工程里了。