Maven:把本地Jar包引入到SpringBoot项目中
实现
-
把jar包放到项目中如
libs
:
-
在
pom.xml
中的dependencies
中引入Jar包:
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/extentreports-3.0.6.jar</systemPath>
</dependency>
- 在
pom.xml
中的build-->plugins-->plugin-->spring-boot-maven-plugin
中添加配置,如下:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 引入本地jar包 -->
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
-
在Dockerfile中把Jar包复制到容器内(没有则忽略)
-
(理论上不需执行,这里只作为备份放在这里)在
pom.xml
中的build
中添加resources
配置,如下:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<!-- 引入本地jar包配置 -->
<resource>
<directory>src/main/resources</directory>
<targetPath>/BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.jpg</include>
<include>**/*.ttf</include>
<include>**/*.xml</include>
<include>**/*.html</include>
<include>**/*.css</include>
<include>**/*.js</include>
<include>**/*.ftl</include>
<include>**/*.TTF</include>
</includes>
<excludes>
<exclude>**/*.jmx</exclude>
</excludes>
</resource>
</resources>
</build>