Nexus是Maven倉(cāng)庫(kù)管理器,用于搭建一個(gè)本地倉(cāng)庫(kù)服務(wù)器,,這樣做的主要的好處就是節(jié)約網(wǎng)絡(luò)資源,,速度快,,開發(fā)團(tuán)隊(duì)中所有的Maven可以共享這個(gè)本地倉(cāng)庫(kù),下載一遍共享使用,。另外一個(gè)優(yōu)點(diǎn)就是他為你的組織提供一個(gè)搭建構(gòu)件的地方,。本文將介紹如何在CentOS系統(tǒng)中安裝配置Nexus,并介紹如何導(dǎo)入已有的構(gòu)件倉(cāng)庫(kù),。 1,、 軟件 a) 下載Nexus 地址:http://www./downloads/nexus-2.1.2-bundle.tar.gz 2,、 安裝 a) 解壓 1 $ tar zxvf nexus-2.1.2-bundle.tar.gz
b) 移動(dòng)到其他目錄 1 $ mv nexus-2.1.2 /home/nexus/nexus
c) 設(shè)置為系統(tǒng)自啟動(dòng)服務(wù)(使用root用戶) 1 # cd /etc/init.d/ 2 # cp /home/nexus/nexus/bin/jsw/linux-x86-64/nexus nexus
編輯/etc/init.d/nexus文件,,添加以下變量定義: 1 NEXUS_HOME=/home/nexus/nexus 2 PLATFORM=linux-x86-64 3 PLATFORM_DIR="${NEXUS_HOME}/bin/jsw/${PLATFORM}"
1 WRAPPER_CMD="${PLATFORM_DIR}/wrapper" 2 WRAPPER_CONF="${PLATFORM_DIR}/../conf/wrapper.conf" 3 PIDDIR="${NEXUS_HOME}" 修改如下變量,設(shè)置啟動(dòng)用戶為nexus: 1 RUN_AS_USER=nexus
執(zhí)行命令添加nexus自啟動(dòng)服務(wù) 1 # chkconfig –add nexus 2 # chkconfig –levels 345 nexus on 執(zhí)行如下命令啟動(dòng),、停止nexus服務(wù) 1 # service nexus start 2 # service nexus stop
d) 檢查是否啟動(dòng)成功 在本機(jī)瀏覽器中訪問URL: http://localhost:8081/nexus e) 修改配置 配置文件位置nexus/conf/nexus.properties,,配置示例如下: 1 # Sonatype Nexus 2 # ============== 3 # This is the most basic configuration of Nexus. 4 5 # Jetty section 6 application-port=8081 7 application-host=0.0.0.0 8 nexus-webapp=${bundleBasedir}/nexus 9 nexus-webapp-context-path=/nexus 10 11 # Nexus section 12 nexus-work=${bundleBasedir}/../sonatype-work/nexus 13 runtime=${bundleBasedir}/nexus/WEB-INF 14 pr.encryptor.publicKeyPath=/apr/public-key.txt 主要配置參數(shù): application-port:nexus啟動(dòng)端口 3、 導(dǎo)入已有的構(gòu)件庫(kù) nexus的構(gòu)件倉(cāng)庫(kù)都保存在sonatype-work目錄中,,該目錄的位置由nexus/conf/nexus.properties配置文件指定,。 1 <repository> 2 <id>central</id> 3 <name>Central</name> 4 <providerRole>org.sonatype.nexus.proxy.repository.Repository</providerRole> 5 <providerHint>maven2</providerHint> 6 <localStatus>IN_SERVICE</localStatus> 7 <notFoundCacheActive>true</notFoundCacheActive> 8 <notFoundCacheTTL>1440</notFoundCacheTTL> 9 <userManaged>true</userManaged> 10 <exposed>true</exposed> 11 <browseable>true</browseable> 12 <writePolicy>READ_ONLY</writePolicy> 13 <indexable>true</indexable> 14 <searchable>true</searchable> 15 <localStorage> 16 <provider>file</provider> 17 <url>file:/home/nexus/sonatype-work/nexus/storage/central</url> 18 </localStorage> 19 <remoteStorage> 20 <provider>apacheHttpClient3x</provider> 21 <url>http://repo1./maven2/</url> 22 <mirrors> 23 <mirror> 24 <id>http://repo./repo/</id> 25 <url>http://repo./repo/</url> 26 </mirror> 27 <mirror> 28 <id>http://gradle./gradle/libs</id> 29 <url>http://gradle./gradle/libs</url> 30 </mirror> 31 <mirror> 32 <id>http://repo.</id> 33 <url>http://repo.</url> 34 </mirror> 35 <mirror> 36 <id>http://repo.maven./maven2</id> 37 <url>http://repo.maven./maven2</url> 38 </mirror> 39 <mirror> 40 <id>http://search.</id> 41 <url>http://search.</url> 42 </mirror> 43 <mirror> 44 <id>http://repo1./maven2/</id> 45 <url>http://repo1./maven2/</url> 46 </mirror> 47 <mirror> 48 <id>http://download./webdav/geotools/</id> 49 <url>http://download./webdav/geotools/</url> 50 </mirror> 51 </mirrors> 52 </remoteStorage> 53 <externalConfiguration> 54 <proxyMode>ALLOW</proxyMode> 55 <artifactMaxAge>-1</artifactMaxAge> 56 <itemMaxAge>1440</itemMaxAge> 57 <cleanseRepositoryMetadata>false</cleanseRepositoryMetadata> 58 <downloadRemoteIndex>true</downloadRemoteIndex> 59 <checksumPolicy>WARN</checksumPolicy> 60 <repositoryPolicy>RELEASE</repositoryPolicy> 61 <autoBlockActive>true</autoBlockActive> 62 <fileTypeValidation>true</fileTypeValidation> 63 <metadataMaxAge>1440</metadataMaxAge> 64 </externalConfiguration> 66 </repository>
|
|