您的位置:首页 > 其它

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

2016-06-14 12:17 501 查看
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参数,如图
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nexus maven deploy SNAPSHOT