有如下依赖
<dependency>
<groupId>kim.nzxy</groupId>
<artifactId>some-name</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/some-name-1.0.0.jar</systemPath>
</dependency>
此时正常打包是无法运行的, 如果是springboot环境, 可以尝试添加includeSystemScope配置:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
如果是多模块项目, 在main方法所在的模块里面添加includeSystemScope即可, 其余模块不必添加
非springboot项目则需要配置resource:
<build>
<resources>
<resource>
<!-- 值为当前pom.xml的相对路径 -->
<directory>lib</directory>
<!-- 要copy的目标路径 -->
<targetPath>/BOOT-INFO/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</resources>
</build>
当依赖设置为systemScope时,正常打包无法运行。对于SpringBoot项目,可添加spring-boot-maven-plugin配置includeSystemScope为true来解决。在多模块项目中,只需在主模块配置。非SpringBoot项目需配置资源,将jar包复制到BOOT-INF/lib目录。

3万+

被折叠的 条评论
为什么被折叠?



