Maven私有库使用说明
1、配置好私服环境,添加其他的proxy Repository地址,这里添加了spring-cloud的库或者aliyun的库;
2、设置私服中库的可见性,具体操作步骤为:
a、点击public repository
b、在configuration中把需要用到的库添加到Available Repositories中,这里可以拖动排序,具体体现在使用的时候优先使用哪个库,然后保存;
3、maven默认的setting.xml文件需要添加打包到私有库的用户信息配置;
<server>
<id>nexus-snapshots</id>
<username>abc</username>
<password>123456</password>
</server>
<server>
<id>nexus-releases</id>
<username>abc</username>
<password>123456</password>
</server>
4、在项目中使用私有库中的jar,具体配置如下:
<!--项目中使用Maven私服-->
<repositories>
<!--公共库-->
<repository>
<id>public</id>
<name>public Repositories</name>
<url>http://maven.xxx.com/nexus/content/groups/public/</url>
</repository>
<!--自己封装的私有库-->
<repository>
<id>releases</id>
<name>Releases Repositories</name>
<url>http://maven.xxx.com/nexus/content/repositories/releases/</url>
</repository>
</repositories>
5、私有库打包,这里需要注意的是:
a、打包的Snapshots包是不能被项目引用的,因为Snapshots包每次打包都是按日期时间生成的jar。
b、打包项目名称包含releases或者直接xxx-1.0.0类似,这里打包到私有库中就是releases版本
6、打包代码到私有库,具体代码如下(这里的id需要和setting.xml文件中server的id一致):
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://maven.xxx.com/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>
以上操作完成,即可在项目中使用自己的私有库!