修改idea使用本地maven配置

32 篇文章 0 订阅
5 篇文章 0 订阅

1.解决的问题

在idea中新创建了springboot项目,但pom中依赖的包总是无法导入。工作的网络不能直接访问外网,需要配置代理。
本地的maven已经做了配置,并把资料库改为了淘宝的。
需要把idea的默认maven改为本地maven。

2.本地maven配置

maven的安装和配置,不在赘述,见:
maven的配置文件:MAVEN_HOME\conf\settings.xml。关键内容如下:

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
<localRepository>D:\Maven\local-repo</localRepository>

<proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>********</host>
      <port>80</port>
      <nonProxyHosts>*******.com.cn</nonProxyHosts>
    </proxy>
  </proxies>

<mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus-aliyun</id>
      <mirrorOf>*</mirrorOf>
      <name>Nexus aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

3.设置idea的maven

Ctrl+Alt+s,【设置】,搜索maven:定位到【Build,Execution,Deployment】【Build Tools】【Maven】,【User setting file】,选定本地maven的配置文件。本地资料库会自动配置中的地址。
在这里插入图片描述

4.导入包检查效果

pom文件一修改,idea会自动提示是否导入,选择导入即可。
导入前【External Libraries】只有JDK的包,成功后,就有Maven自动导入的包了。
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值