nexus-3.6.0-02
如與讀者的有差別請自行參考修正.時間: 2017-10-21 15:05java
nexus下載頁面 根據你所用的操做系統, 選擇對應的版本.apache
直接解壓, 進入以下目錄:瀏覽器
NEXUS_HOME/nexus-3.6.0-02/bin
緩存
執行以下命令:網絡
./nexus run
app
在控制檯看到以下字樣表示nexus啓動成功:jvm
Started Sonatype Nexus OSS 3.6.0-02
打開瀏覽器訪問:maven
http://localhost:8081/
佈局
默認帳號: adminurl
默認密碼: admin123
P.S.
nexus 端口配置:
NEXUS_HOME/sonatype-work/nexus3/etc/nexus-default.properties
# 端口配置 application-port=8081 application-host=0.0.0.0 nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml # 項目名配置 nexus-context-path=/ # 這部分不用管 nexus-edition=nexus-pro-edition nexus-features=\ nexus-pro-feature
nexus 數據存儲配置/內存配置
NEXUS_HOME/sonatype-work/nexus3/etc/nexus-default.properties
這兩個屬性配置存儲目錄: -Dkaraf.data, -Djava.io.tmpdir
這兩個屬性配置內存: -Xms1200M, -Xmx1200M
-Xms1200M -Xmx1200M -XX:MaxDirectMemorySize=2G -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -XX:+LogVMOutput -XX:LogFile=../sonatype-work/nexus3/log/jvm.log -XX:-OmitStackTraceInFastThrow -Djava.net.preferIPv4Stack=true -Dkaraf.home=. -Dkaraf.base=. -Dkaraf.etc=etc/karaf -Djava.util.logging.config.file=etc/karaf/java.util.logging.properties -Dkaraf.data=../sonatype-work/nexus3 -Djava.io.tmpdir=../sonatype-work/nexus3/tmp -Dkaraf.startLocalConsole=false
** maven倉庫分類 **
maven 2(group)
maven倉庫組, 將相同策略的倉庫聚合,並經過一致的地址提供服務
maven 2(hosted)
maven宿主倉庫, 用於發佈內部項目或第三方非開源jar
maven 2(proxy)
maven遠程倉庫代理, 用於進行遠程倉庫的jar包緩存, 團隊內部成員只要有一人下載過jar包, 其它人就無需再到互聯網上遠程的倉庫中下載, 而能夠直接下載nexus緩存的那一份. 節省帶寬, 並提升下載速度.
** maven 倉庫版本政策 **
在項目POM.xml中設置的版本號添加SNAPSHOT標識的都會發布爲SNAPSHOT版本,沒有SNAPSHOT標識的都會發布爲Release版本
如:
Release: 4.3.0 Snapshot: 4.3.0-SNAPSHOT
** maven 倉庫佈局政策 **
該配置會使得全部的遠程jar包下載都經過nexus進行
MAVEN_HOME/conf/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>/Users/pan/maven_repo</localRepository> <!-- offline | 當沒有網絡,只有本地庫,又是用maven來管理項目,在編譯或者下載第三方Jar的時候,總是去中央倉庫上自動下載jar, | 但實際本地已存在這些jar,致使出問題, 那麼就能夠試下使用離線模式 | | 默認值: false <offline>false</offline> --> <pluginGroups> </pluginGroups> <proxies> </proxies> <servers> <!--配置nexus倉庫認證信息--> <server> <id>nexus-releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin123</password> </server> <server> <id>nexus-3rd-party</id> <username>admin</username> <password>admin123</password> </server> </servers> <mirrors> <!-- 全部maven下載都經過本地nexus私服 --> <mirror> <id>nexus</id> <name>local nexus maven</name> <mirrorOf>*</mirrorOf> <url>http://192.168.2.106:8081/repository/maven-public/</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <repositories> <repository> <id>nexus</id> <name>Nexus Repository</name> <url>http://192.168.2.106:8081/repository/maven-public/</url> <layout>default</layout> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>Nexus Repository</name> <url>http://192.168.2.106:8081/repository/maven-public/</url> <layout>default</layout> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles> </settings>
在項目的pom文件中配置:
<distributionManagement> <repository> <id>nexus-releases</id> <name>Nexus Release Repository</name> <url>http://127.0.0.1:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://127.0.0.1:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
ID名稱必需要與settings.xml中Servers配置的ID名稱保持一致
部署命令:
mvn deploy
如: 如第三方JAR包 aliyun-sdk-oss-2.2.3.jar
mvn deploy:deploy-file -DgroupId=com.aliyun.oss -DartifactId=aliyun-sdk-oss -Dversion=2.2.3 -Dpackaging=jar -Dfile=D:\aliyun-sdk-oss-2.2.3.jar -Durl=http://localhost:8081/repository/3rd-party/ -DrepositoryId=nexus-3rd-party