nexus安裝,可以參照:【Maven】Nexus(Maven倉(cāng)庫(kù)私服)下載與安裝
hosted 類型的倉(cāng)庫(kù),內(nèi)部項(xiàng)目的發(fā)布倉(cāng)庫(kù)
releases 內(nèi)部的模塊中release模塊的發(fā)布倉(cāng)庫(kù)
snapshots 發(fā)布內(nèi)部的SNAPSHOT模塊的倉(cāng)庫(kù)
3rd party 第三方依賴的倉(cāng)庫(kù),這個(gè)數(shù)據(jù)通常是由內(nèi)部人員自行下載之后發(fā)布上去
PRoxy 類型的倉(cāng)庫(kù),從遠(yuǎn)程中央倉(cāng)庫(kù)中尋找數(shù)據(jù)的倉(cāng)庫(kù)
group 類型的倉(cāng)庫(kù),組倉(cāng)庫(kù)用來方便我們開發(fā)人員進(jìn)行設(shè)置的倉(cāng)庫(kù)
nexus配置大部分使用默認(rèn)配置即可,主要是配置一個(gè)項(xiàng)目索引
選擇Central倉(cāng)庫(kù),設(shè)置Download Remote Indexes:True
1 <repositories> 2 <repository> 3 <id>nexus</id> 4 <name>nexus</name> 5 <url>http://192.168.1.103:8081/nexus/content/groups/public/</url> 6 <releases> 7 <enabled>true</enabled> 8 </releases> 9 <snapshots>10 <enabled>true</enabled>11 </snapshots>12 </repository>13 </repositories>項(xiàng)目使用nexus私服的插件,在項(xiàng)目的pom.xml文件中指定插件倉(cāng)庫(kù)
1 <pluginRepositories> 2 <pluginRepository> 3 <id>nexus</id> 4 <name>nexus</name> 5 <url>http://192.168.1.103:8081/nexus/content/groups/public/</url> 6 <releases> 7 <enabled>true</enabled> 8 </releases> 9 <snapshots>10 <enabled>true</enabled>11 </snapshots>12 </pluginRepository>13 </pluginRepositories>如果想本機(jī)所有的maven項(xiàng)目都使用私服的組件,可以在maven的設(shè)置文件settings.xml中添加屬性,并激活
1 <profiles> 2 <profile> 3 <id>nexusProfile</id> 4 <repositories> 5 <repository> 6 <id>nexus</id> 7 <name>nexus</name> 8 <url>http://192.168.1.103:8081/nexus/content/groups/public/</url> 9 <releases>10 <enabled>true</enabled>11 </releases>12 <snapshots>13 <enabled>true</enabled>14 </snapshots>15 </repository>16 </repositories>17 </profile>18 </profiles>19 <!-- 激活 -->20 <activeProfiles>21 <activeProfile>nexusProfile</activeProfile>22 </activeProfiles>項(xiàng)目發(fā)布到私服,maven項(xiàng)目使用命令:mvn clean deploy;需要在pom文件中配置一下代碼;
1 <distributionManagement> 2 <repository> 3 <id>user-release</id> 4 <name>User Project Release</name> 5 <url>http://192.168.1.103:8081/nexus/content/repositories/releases/</url> 6 </repository> 7 8 <snapshotRepository> 9 <id>user-snapshots</id>10 <name>User Project SNAPSHOTS</name>11 <url>http://192.168.1.103:8081/nexus/content/repositories/snapshots/</url>12 </snapshotRepository>13 </distributionManagement>注意還需要配置mvn發(fā)布的權(quán)限,否則會(huì)報(bào)401錯(cuò)誤,在settings.xml中配置權(quán)限,其中id要與pom文件中的id一致
1 <server> 2 <id>user-release</id> 3 <username>admin</username> 4 <passWord>admin123</password> 5 </server> 6 <server> 7 <id>user-snapshots</id> 8 <username>admin</username> 9 <password>admin123</password>10 </server>發(fā)布成功后,可以在nexus中看到
上傳第三方的jar包,選擇3rd party-->Artifact Upload--> 選擇GAV方式-->填好構(gòu)建參數(shù)-->增加jar包-->上傳,在Browse Storeage查看
新聞熱點(diǎn)
疑難解答
圖片精選