背景
项目中引用公司私有maven仓库中的。项目上需要构建Jenkins。因网络原因无法连公司私有maven私服。所以需要将公司私有的jar包放下代码中。
技术原理
maven 引用本地项目的jar包
实现步骤
1.1 将私服中的jar包下载到本地
在maven私服中执行mvn install 将私服中的jar 下载到本地仓库。
1.2 将公司中的jar包中添加到lib目录中
![](https://img-blog.csdnimg.cn/293f5da70d2749cdacf91ad5a665ab5e.png)
1.3 将在pom文件改为引用相对路径
<dependency>
<groupId>com.microservice</groupId>
<artifactId>microservice-common</artifactId>
<scope>system</scope>
<systemPath>${project.basedir}/lib/microservice-common-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>
1.4 将maven中的仓库地址改为阿里云的仓库地址,并在仓库中删除原来的jar包进行编译运行
这个步骤相对简单,网上搜索一下很多教程。这里就不复述了。
1.5 在pom中的build spring-boot-maven-plugin 插件中添加
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
1.6 在项目所在根目录执行打包命令
mvn clean package -Dmaven.test.skip=true -U
执行没有报错就证明改动生效了