一、解壓後啓動服務java
執行 E:\Program\nexus\nexus-2.9.1-02\bin\jsw\windows-x86-32 下的 console-nexus.batwindows
二、Nexus啓動報錯: Unsupported major.minor version 51.0app
緣由是jdk版本不匹配,nexus從2.6版本開始就不支持jdk1.6了,換成1.7就能夠了maven
修改 E:\Program\nexus\nexus-2.9.1-02\bin\jsw\conf 下的 wrapper.confui
wrapper.java.command=E:\Program\Java\jdk1.7.0\bin\javathis
三、啓動成功後訪問地址url
http://localhost:8081/nexus/code
四、maven nexus本地庫配置server
<mirror> <id>nexus-public</id> <mirrorOf>public</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://127.0.0.1:8081/nexus/content/groups/public</url> </mirror> <profile> <id>nexus</id> <repositories> <repository> <id>nexus</id> <name>local private nexus</name> <url>http://127.0.0.1:8081/nexus/content/groups/public</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>local private nexus</name> <url>http://127.0.0.1:8081/nexus/content/groups/public</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles>
五、分發構件至遠程倉庫xml
mvn install 會將項目生成的構件安裝到本地Maven倉庫,mvn deploy 用來將項目生成的構件分發到遠程Maven倉庫。本地Maven倉庫的構件只能供當前用戶使用,在分發到遠程Maven倉庫以後,全部能訪問該倉庫的用戶都能使用你的構件。
咱們須要配置POM的distributionManagement來指定Maven分發構件的位置,以下:
<project> <distributionManagement> <repository> <id>user-release</id> <name>Nexus Release Repository</name> <url>http://127.0.0.1:8081/nexus/content/repositories/releases</url> </repository> <snapshotRepository> <id>user-snapshot</id> <name>Nexus Snapshot Repository</name> <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement> </project>
Maven區別對待release版本的構件和snapshot版本的構件,snapshot爲開發過程當中的版本,實時,但不穩定,release版本則比較穩定。Maven會根據你項目的版原本判斷將構件分發到哪一個倉庫。
通常來講,分發構件到遠程倉庫須要認證,若是你沒有配置任何認證信息,你每每會獲得401錯誤。這個時候,以下在settings.xml中配置認證信息:
<server> <id>user-release</id> <username>deployment</username> <password>deployment123</password> </server> <server> <id>user-snapshot</id> <username>deployment</username> <password>deployment123</password> </server>
須要注意的是,settings.xml中server元素下id的值必須與POM中repository或snapshotRepository下id的值徹底一致。將認證信息放到settings下而非POM中,是由於POM每每是它人可見的,而settings.xml是本地的。
配置完成後 執行 mvn deploy,顯示build success代表成功,而後訪問nexus,搜索看能不能找到剛纔發佈的包。找到了就ok了。
六、nexus啓動失敗:The nexus service was launched, but failed to start
多是端口占用形成的,nexus默認端口是8081,若是被佔用則啓動失敗
解決辦法:修改 C:\Program\nexus-2.9.1-02\conf\nexus.properties application-port=8086
七、nexus默認用戶名密碼 admin/admin123 ,有些功能,好比上傳jar包,須要登陸後才能看到