springboot maven 打包引入本地包的几种方法
直接上pom.xml代码(亲测到最简配置)
1、将本地包添加到maven依赖,打包时自动打入:
<dependency>
<groupId>XXX</groupId>
<artifactId>XXX</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/jar/commons-codec-1.10.jar</systemPath>
</dependency>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 同时发布本地引用包 -->
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
注:此方法是将单个包加入依赖,因此本地包过多时,比较费力
2、添加maven插件,指明路径,打包时将本地包也打入:
<!--maven打包时引入本地包-->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>${project.basedir}/lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<targetPath>BOOT-INF/classes/</targetPath>
</resource>
</resources>
