nexus 配置java_Maven项目使用Nexus作为远程仓库的settings.xml配置

Maven项目使用Nexus作为远程仓库的settings.xml配置(转)

在自己电脑C:\Users\hanmm\.m2\下的setting.xml。

1.服务器配置

nexus-releases

admin

123456

nexus-snapshots

admin

123456

id:与Maven想要连接上的repository/mirror中的id元素相匹配。

username,password:这两个元素成对出现,表示连接这个server需要验证username和password。

这里使用两个服务器配置,分别对应release和snapshot。

2.镜像

nexus-releases

*

http://localhost:8081/nexus/content/groups/public

nexus-snapshots

*

http://localhost:8081/nexus/content/groups/public-snapshots

id,name:唯一的镜像标识和用户友好的镜像名称。id被用来区分mirror元素,并且当连接时候被用来获得相应的证书。

mirrorOf:镜像所包含的仓库的Id。例如,指向Maven central仓库的镜像(http://repo1.maven.org/maven2/),设置这个元素为central。更多的高级映射例如repo1,repo2 或者*,!inhouse都是可以的。没必要一定和mirror的id相匹配。在这里mirrorOf项当然应该使用*,以表明是所有仓库都会被镜像到指定的地址。

url:镜像基本的URL,构建系统将使用这个URL来连接仓库。这里应该添nexus仓库的地址,地址可以在nexus仓库页面中找到。

3.配置

nexus

nexus-releases

http://nexus-releases

true

true

nexus-snapshots

http://nexus-snapshots

true

true

nexus-releases

http://nexus-releases

true

true

nexus-snapshots

http://nexus-snapshots

true

true

profile项代表maven的基本配置。按照maven的一贯尿性,很多xml的配置项都会有一个配置项的复数形式作为父节点,以保证该配置项可以配置多个。在profiles项中,当然也可以配置多个profile,不过在这里配一个就够了。下面介绍profile项的各个子节点。

id:用来确定该profile的唯一标识。

repositories/repository:用以规定依赖包仓库的相关信息。在下属节点中,id就不用多说了;URL是指仓库地址,这里使用伪造的地址,否则即使设置了mirror,maven也有可能会直接从中央仓库下载包;releases和snapshots放在一块说吧,这两个节点下属的enable节点用以规定对应的依赖包是否对当前策略有效,假如将snapshot的enable项设为disable,则不会下载snapshot包,这两个节点还有updatePolicy,checksumPolicy和layout属性,这里就不多介绍了,有兴趣的查查文档吧。

pluginRepositories/pluginRepository:用以规定插件仓库的相关信息。其下属节点与repository的相同,不多说了。

4.当前启用配置

nexus

用以规定当前启用的配置,将对应profile的ID加入到这一项即可使profile生效。

5.完整配置

nexus-releases

admin

admin123

nexus-snapshots

admin

admin123

nexus-releases

*

http://localhost:8081/nexus/content/groups/public

nexus-snapshots

*

http://localhost:8081/nexus/content/groups/public-snapshots

nexus

nexus-releases

http://nexus-releases

true

true

nexus-snapshots

http://nexus-snapshots

true

true

nexus-releases

http://nexus-releases

true

true

nexus-snapshots

http://nexus-snapshots

true

true

nexus

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Mavensettings.xml文件中配置阿里云镜像,你可以按照以下步骤进行操作: 1. 下载Maven:你可以从Maven官方网站\[1\]下载Maven,并将其解压到你的计算机上。 2. 打开settings.xml文件:在Maven的安装目录中,找到conf文件夹,里面有一个名为settings.xml的文件。用文本编辑器打开这个文件。 3. 添加阿里云镜像:在settings.xml文件中,找到<mirrors>标签,如果没有的话,可以在<settings>标签下添加一个<mirrors>标签。在<mirrors>标签中,添加以下代码\[2\] \[3\]: <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> <mirrorOf>central</mirrorOf> </mirror> 这段代码将添加一个名为"alimaven"的镜像,将中央仓库(central)的所有请求重定向到阿里云镜像。 4. 保存并关闭文件:在完成配置后,保存settings.xml文件并关闭文本编辑器。 现在,你的Maven就已经配置了阿里云镜像。当你使用Maven进行构建或下载依赖时,它将从阿里云镜像中获取所需的资源。 #### 引用[.reference_title] - *1* *3* [Maven 环境及settings.xml配置(指定本地仓库、阿里云镜像设置)](https://blog.csdn.net/weixin_43691098/article/details/90307851)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Maven阿里云镜像setting.xml配置文件](https://blog.csdn.net/Chen_Sir____/article/details/120809784)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值