码迷,mamicode.com
首页 > 其他好文 > 详细

笔记:Maven 仓库和插件配置本机私服

时间:2017-02-19 18:30:01      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:maven   pos   ack   file   snapshot   black   通过   host   支持   

通过配置POM中的配置仓库和插件仓库,只在当前项目生效,而实际应用中,我们希望通过一次配置就能让本机所有的Maven项目都使用自己的Maven私服,这个时候我们需要配置 settings.xml文件,该文件中的配置对所有本机的Maven项目有效,但是 settings.xml 并不支持直接配置 repositories pluginRepositories,Maven提供了 profile 机制,能让用户将仓库配置放到 settings.xml 中的 profile 中,配置说明如下:

<profiles>

????<profile>

????????<!-- profile 的唯一ID -->

????????<id>innerRepository</id>

????????<!-- 仓库配置 -->

????????<repositories>

???????? <repository>

<!-- 配置为 central 会覆盖超级POM中央仓库的配置 -->

????????????<id>central</id>

????????????<name>inner Repository</name>

????????????<url>http://localhost:8081/nexus/content/groups/public/</url>

????????????<layout>default</layout>

????????????<releases>

????????????????<enabled>true</enabled>

????????????</releases>

????????????<snapshots>

????????????????<enabled>false</enabled>

????????????</snapshots>

???????? </repository>

????????</repositories>

????????<!-- 插件仓库配置-->

????????<pluginRepositories>

????????????<pluginRepository>

<!-- 配置为 central 会覆盖超级POM中央仓库的配置 -->

????????????????<id>central</id>

????????????????<name>public Group</name>

????????????????<url>http://localhost:8081/nexus/content/groups/public/</url>

????????????????<layout>default</layout>

????????????????<releases>

????????????????????<enabled>true</enabled>

????????????????</releases>

????????????????<snapshots>

????????????????????<enabled>false</enabled>

????????????????</snapshots>

????????????</pluginRepository>

????????</pluginRepositories>

????</profile>

</profiles>

然后在 activeProfiles 中启用 profile,配置如下:

<activeProfiles>

????<!-- 激活的 Profile 唯一ID -->

????????<activeProfile>innerRepository</activeProfile>

</activeProfiles>

笔记:Maven 仓库和插件配置本机私服

标签:maven   pos   ack   file   snapshot   black   通过   host   支持   

原文地址:http://www.cnblogs.com/li3807/p/6416214.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!