IDEA设置maven修改settings.xml配置文件无法加载仓库的解决方案
作者:XSpringSun 时间:2023-08-23 22:39:35
出处:https://www.cnblogs.com/SunSpring
作为初学者配置maven一般网上搜索。然后你就看到各种配置文件片段,首先配置镜像,然后配置仓库。完事后再IDEA里面配置下maven的路径和配置文件路径。
这些文章属实坑爹,完全没讲一个重要的配置就是activeProfiles
。
当我配置了各种,捣腾了半天,idea里面死活加载不进去我配置的仓库信息。
最后配置好activeProfiles就行了,这个基本99%的文章都没讲过要配置,自己不仔细去看文档就会掉入陷阱。
activeProfiles 下面配置的是要激活的profile。
<activeProfiles>
<activeProfile>profileid</activeProfile>
</activeProfiles>
maven settings.xml 配置
配置的profile
<profile>
<id>profileid</id>
<repositories>
<repository>
<id>snapshots</id>
<name>snapshots</name>
<url>http://xxx.xxx.xx.xx:8081/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
</profile>
使用的是内部搭建的私有仓库。
镜像和仓库的关系
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
镜像:mirror相当于一个 * ,它会拦截maven对remote repository的相关请求,把请求里的remote repository地址,重定向到mirror里配置的地址。
拦截规则:mirrorOf指定的是哪个就拦截哪个,central就会拦截中央仓库的请求,mirrorOf里面的值是repository的id值。比如我把central换成上面我私有仓库id的snapshots,那么私有仓库的请求会被转到镜像,当然我们并不需要这样。
仓库:仓库是项目中依赖的第三方库,这个库所在的位置叫做仓库。
所以并不是仓库和镜像都要配置,许多文章也没意识到这点,如果我只用内部搭建的私有仓库根本不需要去配什么镜像。
idea 配置maven
file->settings
配置好后刷新下重新加载,下载maven依赖
如果不好使,关掉idea再重开,idea会抽风
来源:https://www.cnblogs.com/SunSpring/p/13807804.html
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
java内存模型jvm虚拟机简要分析
![](https://img.aspxhome.com/file/2023/3/101933_0s.jpg)
asp.net之生成验证码的方法集锦(一)
详解android 人脸检测你一定会遇到的坑
![](https://img.aspxhome.com/file/2023/1/118951_0s.jpg)
Java实现读写文件功能的代码分享
![](https://img.aspxhome.com/file/2023/3/78983_0s.png)
SpringCloud eureka(server)微服务集群搭建过程
![](https://img.aspxhome.com/file/2023/4/69104_0s.jpg)
C#文件下载实例代码(适用于各个浏览器)
Android应用程序的编译流程及使用Ant编译项目的攻略
![](https://img.aspxhome.com/file/2023/4/126694_0s.jpg)
c#中oracle的to_date函数使用方法
深入理解java动态代理的两种实现方式(JDK/Cglib)
java多线程下载实例详解
![](https://img.aspxhome.com/file/2023/9/116179_0s.png)
Java字符判断的小例子
![](https://img.aspxhome.com/file/2023/9/58169_0s.jpg)
C# TabControl控件中TabPage选项卡切换时的触发事件问题
![](https://img.aspxhome.com/file/2023/9/85739_0s.png)
C#将配置文件appsetting中的值转换为动态对象调用
C#实现串口示波器
![](https://img.aspxhome.com/file/2023/2/98252_0s.jpg)
Android使用Handler实现下载文件功能
![](https://img.aspxhome.com/file/2023/3/137943_0s.gif)
Java并发编程之ReadWriteLock读写锁的操作方法
![](https://img.aspxhome.com/file/2023/8/86698_0s.png)
JDK集合源码之解析TreeMap(一)
![](https://img.aspxhome.com/file/2023/3/66643_0s.png)