Maven Setting.xml配置- <?xml version="1.0" encoding="utf-8"?>
- <settings xmlns="http://maven./SETTINGS/1.0.0" xmlns:xsi="http://www./2001/XMLSchema-instance" xsi:schemaLocation="http://maven./SETTINGS/1.0.0 http://maven./xsd/settings-1.0.0.xsd">
- <!-- 本地倉庫配置 -->
- <localRepository>D:\java\mavenRepos</localRepository>
- <pluginGroups>
- </pluginGroups>
- <proxies>
- </proxies>
- <!-- 服務(wù)用戶配置 -->
- <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>
關(guān)于發(fā)布到nexus倉庫中,使用mvn deploy命令
eclipse中配置run configuration中加入deploy參數(shù),如圖
發(fā)布項(xiàng)目到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,否則報(bào)錯(cuò),當(dāng)時(shí)也是被坑了個(gè)first blood出來..
關(guān)于SNAPSHOT版本簡單介紹一下
如pom.xml中配置<version>1.0.0-SNAPSHOT</version>
表示快照版本,版本雖為1.0.0,但是每次都會(huì)使用最新的版本,參考nexus倉庫截圖,每次提交都會(huì)產(chǎn)生不同的版本號(hào)
關(guān)于發(fā)布到nexus倉庫中,使用mvn deploy命令
eclipse中配置run configuration中加入deploy參數(shù),如圖
|