51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

nexus配置阿里云仓库(maven 配置nexus 私服)

nexus配置阿里云仓库

上篇一篇我们在linux上 做了 nexus安装 :https://www.baimeidashu.com/9880.html

这一篇我们设置nexus3配置阿里云仓库

1nexus配置阿里云仓库

阿里云 maven 源

http://maven.aliyun.com/nexus/content/groups/public

然后点击save 保存

我们用的时候 点击 public

默认的是从这3个仓库里找, 找不到就去 代理Proxy 里找。

2maven 配置nexus 私服

我们怎么使用呢?

就是把我们本地 maven 修改一下配置文件就可以

这个修改后的 setting.xml 我 给大家保存在了云盘上

nexus: https://url69.ctfile.com/d/253469-56163475-117455?p=2206 (访问密码: 2206)

/usr/local/maven/conf

vim settings.xml

Nexus 安装成功后,接下来需要修改 Maven 的配置文件(settings.xml),整合 Nexus。

(1) 找到 <servers> 标签,添加 Nexus 默认认证信息:

<server>   
    <id>my-nexus-releases</id>   
    <username>admin</username>   
    <password>admin123</password>   
  </server>   
  <server>   
    <id>my-nexus-snapshot</id>   
    <username>admin</username>   
    <password>admin123</password>   
  </server>

(2)找到 <mirrors> 标签,添加镜像:

<mirror>
  <!--This sends everything else to /public -->
  <id>nexus</id>
  <mirrorOf>*</mirrorOf>
  <url>http://10.0.0.202:8081/repository/maven-public/</url>
</mirror>

(3)找到 <profiles> 标签,添加仓库信息:

<profile>
  <id>nexus</id>
  <repositories>
    <repository>
      <id>central</id>
      <url>http://10.0.0.202:8081/repository/maven-public/</url>
      <releases><enabled>true</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
    </repository>
  </repositories>
 <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <url>http://10.0.0.202:8081/repository/maven-public/</url>
      <releases><enabled>true</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
    </pluginRepository>
  </pluginRepositories>
</profile>
  </profiles>

(4) 激活仓库:

<activeProfiles>
  <!--make the profile active all the time -->
  <activeProfile>nexus</activeProfile>
</activeProfiles>
  

配置完成后保存,并重启 nexus 服务。

/usr/local/nexus/bin/nexus restart

重启 nexus 服务 完成后,在命令行窗口进入一个使用 Maven 构建的项目,输入 mvn package clean 命令,

清理完成后,登录 nexus 的 admin 账号可以看到 Public Repositories 下出现了一些 Jar 包。

这样以后 只要仓库有的 ,就会从本地下载了。 速度就快了。

赞(1)
未经允许不得转载:工具盒子 » nexus配置阿里云仓库(maven 配置nexus 私服)