Maven使用nexus配置,SNAPSHOT版本介绍及发布jar到nexus

Maven Setting.xml配置
<?xml version="1.0" encoding="utf-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- 本地仓库配置 -->
<localRepository>D:\java\mavenRepos</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<!-- 服务用户配置 -->
<servers>
<server>
<id>releases</id>
<username>deployment</username>
<password>cykj</password>
</server>
<server>
<id>snapshots</id>
<username>deployment</username>
<password>cykj</password>
</server>
</servers>
<!-- 镜像配置 -->
<mirrors>
<!-- 对snapshots版本有效 -->
<mirror>
<id>nexusSnapashots</id>
<url>http://192.168.2.18:8081/nexus/content/groups/public/</url>
<mirrorOf>public-snapshots</mirrorOf>
<interval>always</interval>
</mirror>
<mirror>
<id>nexusMirror</id>
<name>local repos</name>
<url>http://192.168.2.18:8081/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<!-- 条件配置 -->
<profiles>
<profile>
<id>nexusRepository</id>
<!-- jar包仓库配置 -->
<repositories>
<repository>
<id>nexusSnapashots</id>
<name>nexus-snapshots</name>
<url>http://192.168.2.18:8081/nexus/content/groups/public/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
<repository>
<id>nexusMirror</id>
<name>nexus-snapshots</name>
<url>http://192.168.2.18:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
<!-- 插件仓库配置 -->
<pluginRepositories>
<pluginRepository>
<id>nexusMirror</id>
<name>nexus mirror</name>
<url>http://192.168.2.18:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>  
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- 激活profile -->
<activeProfiles>
<activeProfile>nexusRepository</activeProfile>
</activeProfiles>
</settings>

关于发布到nexus仓库中,使用mvn deploy命令

eclipse中配置run configuration中加入deploy参数,如图


发布项目到nexus上在pom.xml中加入

<distributionManagement>
		<repository>
			<id>releases</id>
			<name>Nexus Releases Repository</name>
			<url>http://192.168.2.18:8081/nexus/content/repositories/releases/</url>
		</repository>
		<snapshotRepository>
			<id>snapshots</id>
			<name>Nexus Snapshots Repository</name>
			<uniqueVersion>false</uniqueVersion>
			<layout>legacy</layout>
			<url>http://192.168.2.18:8081/nexus/content/repositories/snapshots/</url>
		</snapshotRepository>
	</distributionManagement>
注意id与setting中server的id保持一致
server中配置的用户名密码为nexus中的用户id和密码,注意是id不是name,否则报错,当时也是被坑了个first blood出来..

关于SNAPSHOT版本简单介绍一下

如pom.xml中配置<version>1.0.0-SNAPSHOT</version>

表示快照版本,版本虽为1.0.0,但是每次都会使用最新的版本,参考nexus仓库截图,每次提交都会产生不同的版本号


关于发布到nexus仓库中,使用mvn deploy命令

eclipse中配置run configuration中加入deploy参数,如图

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值