1. 程式人生 > >6、Maven私有庫和本地庫的安裝與配置(Sonatype Nexus +Manven)

6、Maven私有庫和本地庫的安裝與配置(Sonatype Nexus +Manven)

Maven私有庫和本地庫的安裝與配置(Sonatype Nexus +Manven) 環境:JDK1.8、 CenterOS 6.5 、Sonatype Nexus 、Maven IP 192.168.159.138 root使用者操作 2、解壓 # mkdir nexus # cd nexus # ls nexus-2.14.5-02 sonatype-work (一個nexus服務,一個私有庫目錄) 3、編輯Nexus 的nexus.properties 檔案,配置埠和work目錄資訊(保留預設) # cd nexus-2.14.5-02 # ls bin conf lib LICENSE.txt logs nexus NOTICE.txt tmp 檢視目錄結構,jetty執行 # cd conf # vi nexus.properties # Jetty section application-port=8081
application-host=0.0.0.0 nexus-webapp=${bundleBasedir}/nexus nexus-webapp-context-path=/nexus : # Nexus section nexus-work=${bundleBasedir}/../sonatype-work/nexus runtime=${bundleBasedir}/nexus/WEB-INF # orientdb buffer size in megabytes storage.diskCache.bufferSize=4096 4、編輯nexus指令碼,配置RUN_AS_USER引數 # vi /nexus/nexus-2.14.5-02/bin/nexus #RUN_AS_USER= 改為 RUN_AS_USER=root 5、防火牆開啟8081埠 # vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8081-j ACCEPT 重啟防火牆 service iptables restart 6、啟動 nexus # /nexus/nexus-2.14.5-02/bin/nexus start


8、登入,預設使用者名稱:admin,預設密碼:admin123 至此,Nexus已安裝完成,接下來是Nexus的配置 Nexus配置(登入後) 1、開啟Administration/Server 配置郵箱地址(如果忘記密碼,可以通過郵箱找回密碼) 2、通過Security/User修改使用者的繫結郵箱 3、Repositories 倉庫屬性介紹


4、設定 proxy 代理倉庫,(Apache Snapshots/Central/Codehaus Snapshots) 准許遠端下載 如:
5、Maven 本地庫的安裝與配置 環境變數、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"> <interactiveMode>true</interactiveMode> <pluginGroups> <pluginGroup>com.mortbay.jetty</pluginGroup> <pluginGroup>com.jenkins-ci.tools</pluginGroup> </pluginGroups> <proxies> </proxies> <!-- 配置許可權,使用預設使用者--> <servers> <server> <id>nexus-releases</id> <username>deployment</username> <password>deployment123</password> </server> <server> <id>nexus-snapshots</id> <username>deployment</username> <password>deployment123</password> </server> </servers> <mirrors> </mirrors> <profiles> <profile> <id>com-njztc</id> <activation> <activeByDefault>false</activeByDefault> <jdk>1.7</jdk> </activation> <repositories> <!--私有庫地址--> <repository> <id>nexus</id> <url>http://192.168.159.138/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <!--外掛庫地址--> <pluginRepository> <id>nexus</id> <url>http://192.168.159.138/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>com-njztc</activeProfile> </activeProfiles> <localRepository>C:\local-private-maven\repository</localRepository> </settings> 6、IDE工具中的Maven配置

7、專案的構建與釋出演示 修改common-parent 中的pom.xml中的私有庫地址