修改IDEA中maven的本地仓库 intellij idea使用maven本地仓库及修改本地仓库路径

intellij idea使用maven本地仓库及修改本地仓库路径

什么maven本地仓库,默认是用户目录下的.m2/repository这个文件。现在在网上搜,idea怎么使用maven?很多都还说要下载maven插件的,其实idea是自带maven插件的,所以不用我们再下载什么?怎么把依赖包下载到我们的本地仓库呢?一般是idea默认了路径,而且idea是没有所谓的setting.xml配置的,更新依赖r包,我们只需要更改pom.xml配置就好,写好依赖包注释,就能把依赖包下载到本地仓库了。我们也可以更改本地仓库的路径,但是网上的配置都是很多的,我们只需要一项就可以了,以下是本地仓库路径配置文件:

手动创建一个settings.xml 的文件,把下面的代码复制进去即可,标红色的为仓库路径,可以自行更改。

<?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>D:/maven/my_local_repository</localRepository>
  

</settings>
简单配置一下就可以,太多反而可能造成依赖包不能正确加载!

以下为修改本地仓库路径:


有一天 公司的maven仓库 挂了,就是用了阿里的库
最后附加一个 使用阿里maven仓库的教程

阿里仓库地址

https://maven.aliyun.com/mvn/search

如何使用阿里云maven仓库
https://www.cnblogs.com/jimlau/p/12156540.html

1.setting文件增加

<mirror>  
  <id>alimaven</id>  
  <name>aliyun maven</name>  
  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>;  
  <mirrorOf>central</mirrorOf>          
</mirror>

2.pom

<repositories><!-- 代码库 -->
   <repository>
      <id>maven-ali</id>
      <url>http://maven.aliyun.com/nexus/content/groups/public//</url>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>true</enabled>
         <updatePolicy>always</updatePolicy>
         <checksumPolicy>fail</checksumPolicy>
      </snapshots>
   </repository>
</repositories>
发布了21 篇原创文章 · 获赞 6 · 访问量 9322

猜你喜欢

转载自blog.csdn.net/qq1032350287/article/details/95764370