Nexus是Maven仓库管理器,用于搭建一个本地仓库服务器,这样做的主要的好处就是节约网络资源,速度快,开发团队中所有的Maven可以共享这个本地仓库,下载一遍共享使用。另外一个优点就是他为你的组织提供一个搭建构件的地方。本文将介绍如何在CentOS系统中安装配置Nexus,并介绍如何导入已有的构件仓库。 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) 移动到其他目录 1 $ mv nexus-2.1.2 /home/nexus/nexus
c) 设置为系统自启动服务(使用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}" 修改如下变量,设置启动用户为nexus: 1 RUN_AS_USER=nexus
执行命令添加nexus自启动服务 1 # chkconfig –add nexus 2 # chkconfig –levels 345 nexus on 执行如下命令启动、停止nexus服务 1 # service nexus start 2 # service nexus stop
d) 检查是否启动成功 在本机浏览器中访问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 主要配置参数: application-port:nexus启动端口 3、 导入已有的构件库 nexus的构件仓库都保存在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>
|
|
来自: recruits > 《MAVEN仓库管理》