1. 程式人生 > 實用技巧 >[Maven]Nexus 安裝與配置

[Maven]Nexus 安裝與配置

2019獨角獸企業重金招聘Python工程師標準>>> hot3.png

轉載於:http://w26.iteye.com/blog/1547096

1
下載Nexus
http://www.sonatype.org/nexus/go

2
安裝
解壓即可
D:\bisoft\tools
nexus-2.0.4-1
sonatype-work

3
配置環境變數
NEXUS_HOME=D:\bisoft\tools\nexus-2.0.4-1
PATH 新增 %NEXUS_HOME%\bin\jsw\windows-x86-64

$NEXUS_HOME/conf/nexus.properties 可修改基本配置資訊,如 sonatype-work 目錄位置.


nexus-work=${bundleBasedir}/../sonatype-work/nexus

4
故障解決方案:
The nexus-webapp service was launched, but failed to start.

環境變數|系統變數|JAVA_HOME & PATH.
注意是系統變數下,不是使用者變數.

5
執行
install-nexus.bat
console-nexus.bat
nexus start|stop

檢視日誌
%NEXUS_HOME%/logs/wrapper.log

6
進入Nexus管理介面
http://localhost:8081/nexus
管理員
賬號:admin
密碼:admin123


部署使用者:
deployment
deployment123

匿名使用者:


7
$NEXUS_HOME/conf/wrapper-override.conf 可重寫nexus服務配置.

8
啟用遠端索引下載
左邊| Repositories|選擇一個遠端代理倉庫|下邊Tab Configuration|Download Remote Indexes|true|Save|上邊選單Refresh.



預設有三個代理倉庫:
Maven Central repository
Apache Snapshot repository
Codehaus Snapshot repository

現在自動開始下載索引檔案.這個只會下載索引,不會下載JAR.除非手動下載啦.


9
手動下載:
下邊TAB Brower Index | 找到JAR | 右邊 |download.
現在,在D:\bisoft\tools\sonatype-work\nexus\storage\central\中快取了JAR包.

10
安裝為服務
64位執行 nexus.bat install 報錯,原因是許可權不啦.

解決辦法:
新建一個nexus-install.bat:
nexus.bat install

然後右鍵|以管理員身份執行(好像管理員必須要密碼才行....)

11
管理組,組是一個很好的東西,它能組合多個倉庫並對映到一個URL上.
Nexus 預設提供一個組:Public Repositories.




Ordered Group Repositories:新加的倉庫,將倉庫加入其中即可.


12
改變nexus監聽埠
$NEXUS_HOME/conf/nexus.properties
application-port=8081

13
配置 Maven
%user.dir%/.m2/settings.xml

Xml程式碼 收藏程式碼
  1. <?xmlversion="1.0"encoding="UTF-8"?>
  2. <settingsxmlns="http://maven.apache.org/SETTINGS/1.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0http://maven.apache.org/xsd/settings-1.0.0.xsd">
  5. <localRepository>D:\bisoft\tools\maven3\repository</localRepository>
  6. <pluginGroups>
  7. <pluginGroup>org.mortbay.jetty</pluginGroup>
  8. <pluginGroup>org.codehaus.cargo</pluginGroup>
  9. </pluginGroups>
  10. <proxies>
  11. </proxies>
  12. <servers>
  13. <server>
  14. <id>releases</id>
  15. <username>admin</username>
  16. <password>admin123</password>
  17. </server>
  18. <server>
  19. <id>snapshots</id>
  20. <username>admin</username>
  21. <password>admin123</password>
  22. </server>
  23. </servers>
  24. <mirrors>
  25. <mirror>
  26. <id>nexus</id>
  27. <mirrorOf>*</mirrorOf>
  28. <url>http://localhost:8081/nexus/content/groups/public</url>
  29. </mirror>
  30. </mirrors>
  31. <profiles>
  32. <profile>
  33. <id>nexus</id>
  34. <repositories>
  35. <repository>
  36. <id>central</id>
  37. <url>http://central</url>
  38. <releases><enabled>true</enabled></releases>
  39. <snapshots><enabled>true</enabled></snapshots>
  40. </repository>
  41. </repositories>
  42. <pluginRepositories>
  43. <pluginRepository>
  44. <id>central</id>
  45. <url>http://central</url>
  46. <releases><enabled>true</enabled></releases>
  47. <snapshots><enabled>true</enabled></snapshots>
  48. </pluginRepository>
  49. </pluginRepositories>
  50. </profile>
  51. </profiles>
  52. <activeProfiles>
  53. <activeProfile>nexus</activeProfile>
  54. </activeProfiles>
  55. </settings>
  56. </settings>


配置部署
pom.xml

Xml程式碼 收藏程式碼
  1. <distributionManagement>
  2. <repository>
  3. <id>releases</id>
  4. <name>InternalReleases</name>
  5. <url>http://localhost:8081/nexus/content/repositories/releases</url>
  6. </repository>
  7. <snapshotRepository>
  8. <id>Snapshots</id>
  9. <name>InternalSnapshots</name>
  10. <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
  11. </snapshotRepository>
  12. </distributionManagement>



14
上傳第三方包
14.1 
mvn deploy:deploy-file -Dgroup -Dartifact
-Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar
-Durl=http://localhost:8081/nexus/content/repositories/thirdparty
-Drepository

14.2
直接複製到倉庫

14.3
介面上傳

15.
備份

直接備份 sonatype-work 目錄即可.

轉載於:https://my.oschina.net/91jason/blog/370137