Linux中安装Nexus+Maven

下载并安装nexus-2.14.8-01-bundle.tar.gz

https://www.sonatype.com/download-sonatype-trial?submissionGuid=c6b88dc4-bda4-41c8-a41a-19e66ecd35d3

上传到192.168.0.239的Linux虚拟机目录/usr/local中



解压

tar -zxvf nexus-2.14.8-01-bundle.tar.gz -C /usr/local/

mv nexus-2.14.8-01 nexus

查看nexus.properties,使用jetty作为容器

vi /usr/local/nexus/conf/nexus.properties

编辑nexus对应脚本,修改RUN_AS_USER

vi /usr/local/nexus/bin/nexus




启动Nexus

sh  /usr/local/nexus/bin/nexus  start


查看Nexus服务页面

在本地Windows机器浏览器中访问http://192.168.0.239:8081/nexus




Nexus设置为开机启动

vi /etc/rc.d/rc.local

添加 /usr/local/nexus/bin/nexus  start


修改wrapper.conf

vi /usr/local/nexus/bin/jsw/conf/wrapper.conf

wrapper.java.command=/usr/local/localsoftware/jdk1.8.0_121/bin/java


重启Linux系统,启动后在本地Windows机器上访问http://192.168.0.239:8081/nexus ,使用admin/admin123登录




Maven下载与安装



下载apache-maven-3.5.3-bin.tar.gz,上传至192.168.0.239Linux虚拟机的/usr/local目录

解压

tar -zxvf apache-maven-3.5.3-bin.tar.gz -C /usr/local/


配置maven环境变量

vi /etc/profile

添加MAVEN_HOME

export MAVEN_HOME=/usr/local/apache-maven-3.5.3

修改PATH 

export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$ZOOKEEPER_HOME/bin:$STORM_HOME/bin:$PATH

设置环境变量生效

source /etc/profile


配置maven的settings.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">  
    
    <pluginGroups></pluginGroups>  
    <proxies></proxies>  
    <!--本地仓库的位置 -->
    <localRepository>/usr/local/local_repository</localRepository>
    
    <!--私服的验证信息 -->
    <servers>  
       <server>  
       <id>nexus-releases</id>  
       <username>admin</username>  
       <password>admin123</password>  
     </server>  
     <server>  
       <id>nexus-snapshots</id>  
       <username>admin</username>  
       <password>admin123</password>  
     </server>  
   </servers>  
   
   <!--maven对全部仓库的访问拦截到私服,若私服关闭,则不会去中央仓库下载jar包 -->
   <mirrors>   
     <mirror>   
       <id>nexus-releases</id>   
       <mirrorOf>*</mirrorOf>   
       <url>http://192.168.0.239:8081/nexus/content/groups/public</url>   
     </mirror>  
     <mirror>   
       <id>nexus-snapshots</id>   
       <mirrorOf>*</mirrorOf>   
       <url>http://192.168.0.239:8081/nexus/content/groups/public-snapshots</url>   
     </mirror>   
   </mirrors>   
    
   <!--配置仓库的一些信息,用于覆盖maven中央仓库的一些配置 --> 
   <profiles>  
    <profile>  
       <id>nexus</id>  
       <repositories>  
         <repository>  
           <id>nexus-releases</id>  
           <url>http://192.168.0.239:8081/nexus/content/groups/public</url>  
           <releases><enabled>true</enabled></releases>  
           <snapshots><enabled>true</enabled></snapshots>  
         </repository>  
         <repository>  
           <id>nexus-snapshots</id>  
           <url>http://192.168.0.239:8081/nexus/content/groups/public-snapshots</url>  
           <releases><enabled>true</enabled></releases>  
           <snapshots><enabled>true</enabled></snapshots>  
         </repository>  
       </repositories>  
       <pluginRepositories>  
          <pluginRepository>  
                 <id>nexus-releases</id>  
                  <url>http://nexus-releases</url>  
                  <releases><enabled>true</enabled></releases>  
                  <snapshots><enabled>true</enabled></snapshots>  
                </pluginRepository>  
               <pluginRepository>  
                  <id>nexus-snapshots</id>  
                   <url>http://nexus-snapshots</url>  
                 <releases><enabled>true</enabled></releases>  
                  <snapshots><enabled>true</enabled></snapshots>  
              </pluginRepository>  
          </pluginRepositories>  
     </profile>  
   </profiles>

   <!--激活上面配置的仓库信息 -->     
   <activeProfiles>  
       <activeProfile>nexus</activeProfile>  
   </activeProfiles>      
 </settings>  

新建本地仓库的目录

mkdir /usr/local/local_repository



Maven项目配置私服+发布到私服

<!-- 配置私服工厂 -->   
<repositories>
	<repository>
		<id>nexus</id>
		<url>http://192.168.0.239:8081/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.0.239:8081/nexus/content/groups/public/</url>
		<releases>
			<enabled>true</enabled>
		</releases>
		<snapshots>
			<enabled>true</enabled>
		</snapshots>
	</pluginRepository>
</pluginRepositories>

<!-- 配置发布到私服 -->
<distributionManagement>  
        <!-- 两个ID必须与 setting.xml中的<server><id>nexus-releases</id></server>保持一致-->  
        <repository>  
            <id>nexus-releases</id>  
            <name>Nexus Release Repository</name>  
            <url>http://192.168.0.239:8081/nexus/content/repositories/releases</url>  
        </repository>  
        <snapshotRepository>  
            <id>nexus-snapshots</id>  
            <name>Nexus Snapshot Repository</name>  
            <url>http://192.168.0.239:8081/nexus/content/repositories/snapshots</url>  
        </snapshotRepository>  
</distributionManagement>
  




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值