nexus 搭建私服简单步骤

本文详细介绍了如何使用Nexus配置Maven远程仓库,包括下载、解压、启动Nexus,设置登录信息,修改项目pom.xml以配置Nexus仓库,以及通过命令行执行编译命令来从Nexus仓库获取依赖。此外,还介绍了如何使用镜像功能进一步优化依赖获取过程。

1. 下载nexus:http://www.sonatype.org/nexus/go, 我下载的是nexus-2.12.1-01-bundle.zip

2. 解压缩包到本地,包含两个文件夹:nexus-2.12.1-01, sonatype-work

3. 进入文件夹:nexus-2.12.1-01\bin\jsw\windows-x86-64, 启动nexus

C:\software\apache-maven-3.3.9\nexus-2.12.1-01\bin\jsw\windows-x86-64>console-nexus

4. open site: http://localhost:8081/nexus/

5. login with: admin/admin123

6. set true to 'download remote indexes'

  • 7 method 1

7.1. modify project pom.xml

   <repositories>
        <repository>
             <id>nexus</id>
             <name>Team Nexus Repository</name>
              <url>http://localhost:8081/nexus/content/groups/public</url>
         </repository>
     </repositories>
     <pluginRepositories>
         <pluginRepository>
             <id>nexus</id>
             <name>Team Nexus Repository</name>
             <url>http://localhost:8081/nexus/content/groups/public</url>
         </pluginRepository>

     </pluginRepositories>
     <dependencies>
       <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

7.2. execute command:

C:\software\apache-maven-3.3.9\lyrepo\my-webapp>mvn compile

will retrieve the jars from http://localhost:8081/nexus

  • 8. method 2: using mirror

8.1 set settings.xml

<mirror>  
      <id>my-org-repo</id>  
      <name>Repository in My Orgnization</name>  
      <url>http://localhost:8081/nexus/content/groups/public/</url>  
      <mirrorOf>central</mirrorOf>  
    </mirror> 

8.2. execute command:

C:\software\apache-maven-3.3.9\lyrepo\my-webapp>mvn compile

will retrieve the jars from http://localhost:8081/nexus



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值