maven配置多仓库的方法
目录
- 改掉原有的maven仓库地址,让maven从公网上摘取jar包下载,方便、快捷。
- 添加一个类似结构的仓库配置,这样的话就不切来切去的了,一劳永逸。
- 按照最简单的方式,新增一个仓库地址,随时切换。
- 无法拉取包的困惑?你可能发现,你的maven无法拉取 SNAPSHOT 包,然而包明明就在那里!
- 一个完整的配置样例参考
- 另附一个idea maven配置的方法
刚接触maven就是在公司里配置好的,所以一直以来使用都没毛病,所以一直没有去动这些固有的东西。
但是,后来把公司的电脑拿回家之后,发现有的东西就搞不起来了。原因也看一下就明白了,因为在公司的时候用的是公司的maven私服,所以回家后,用不了也是正常。
但是,真的脱离了公司,自己就不能工作了吗?不可能吧。 难道一下开源工具都必须要依赖于公司的网络? 这明显是不合理的。
那么,就扯出本次文章的意义了,在家里,自然是要公有的maven仓库了,那么,怎样配置maven仓库才能让自己用起来顺心呢?
返回顶部
- 改掉原有的maven仓库地址,让maven从公网上摘取jar包下载,方便、快捷。
原私有配置示例如下:
<?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">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository -->
<localRepository>${user.home}/.m2/repository</localRepository>
<!--pluginGroups></pluginGroups-->
<!--proxies></proxies-->
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>123</password>
</server>
</servers>
<pluginRepositories>
<pluginRepository>
<id>mypublic</id>
<name>Public</name>
<url>http://test.nexus.com/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
<mirrors>
<mirror>
<id>central</id>
<name>internal</name>
<url>http://test.nexus.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snap