正常<scope>system</scope>的依赖是不会打进包的
假设项目中有个jar包(gson-2.8.5.jar)需要通过<scope>system</scope>的形式打包
如果你的项目打的是jar包
<packaging>jar</packaging>
那么配置<includeSystemScope>true</includeSystemScope>就可以把jar打进去
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
如果你的项目打的是war包
<packaging>war</packaging>
如果配置了<includeSystemScope>true</includeSystemScope>
打war包不会将本地jar包打入\WEB-INF\lib 下,而是在 \WEB-INF\lib-provided 下
需要在 <build> <plugins> 下添加或修改maven-war-plugin配置
<directory></directory> 内为你项目里存放lib的路径,这里是src/main/resources/lib
<targetPath></targetPath> 是目标路径,打入 WEB-INF/lib/
<include></include> 所有jar包
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/resources/lib</directory>
<targetPath>WEB-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
附:maven配置引入本地jar包
假设项目中需要引入本地ar包(gson-2.8.5.jar)
首先配置一个基础路径
<properties>
<locallib.path>${project.basedir}/src/main/resources/lib</locallib.path>
</properties>
然后配置项目路径中的jar包
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>system</scope>
<systemPath>${locallib.path}/gson-2.8.5.jar</systemPath>
</dependency>
或者直接指定路径
<!-- 浙江政务2.0 -->
<dependency>
<groupId>com.alibaba.gov</groupId>
<artifactId>atg-sdk-java</artifactId>
<version>RELEASE20210107143535</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/atg-sdk-java-RELEASE20210107143535.jar</systemPath>
</dependency>
加了plugin之后可能会报错