一、使用背景
1.xxx-component-log是本地开发的一个日志包,2个项目需要同时使用
2.不想上传到私有仓储,同时要求使用Jenkins发布
3.采用方案:引用本地Jar包打包
二、解决办法
1.加scope和systempath
注意加在最外层pom(由于项目结构复杂,开始没有放最外层,踩了很多坑都没有发布成功)
<dependency> <groupId>com.xxx</groupId> <artifactId>xxx-component-log</artifactId> <version>1.0-SNAPSHOT</version> <scope>system</scope> <systemPath>${project.basedir}/../../lib/xxx-component-log-1.0-SNAPSHOT.jar </systemPath> </dependency>
2.在最外层的pom添加includeSystemScope和repackage
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.0.0.RELEASE</version> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>