maven的settings.xml配置

如果你有代理,能科学上网,那么这种方式最好不过

IDEA的settings.xml在C:\Users\[用户名]\.m2目录下,settings.xml可以告诉IDEA通过那种哪下载jar,不必每次直连maven中央仓库,况且有的地方根本连不上

注:目前湖南电信和湖南联通直连maven中央仓库没问题,不需要设置settings.xml,但是湖南长城宽带无法链接,想测连通性的可以用ping或mtr命令测一下repo.maven.apache.org

settings.xml可以配置如下代理的方式,如果是自建跳板,可能还需要认证的参数,本地运行的科学上网软件用这个就可以了,最多改一下port端口号

<?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">

 <proxies>
    <proxy>
      <id>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>127.0.0.1</host>   <!-- Put the IP address of your proxy server here -->
      <port>8580</port>            <!-- Put your proxy server's port number here -->
      <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts> <!-- Do not use this setting unless you know what you're doing. -->
    </proxy>    
  </proxies> 
</settings>

还有一种方式是使用maven镜像,这种方式建议作为备选,镜像这个东西并不是长久之计,曾有公司线上直接使用某RubyGems镜像,结果镜像一挂,服务也挂。如果线上环境如果使用了镜像,最好配置多个,方便切换,还需要做个实时监测。目前有一部分高校,公司,个人建镜像只是为了跟风,觉得别人有我们也不能少,但后期维护跟不上,有的挂了一两个月,有的后来就没有后来了。

下面配置的是阿里云和ibiblio镜像,目前来说这两个镜像比较稳定

<?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">
	<mirrors>
		<mirror>
		    <id>alimaven</id>
		    <name>aliyun maven</name>
		    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
		    <mirrorOf>central</mirrorOf>        
		</mirror>
		<mirror>    
			<id>ibiblio</id>    
			<mirrorOf>central</mirrorOf>    
			<name>Human Readable Name for this Mirror.</name>    
			<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>    
		</mirror>  
	</mirrors>
</settings>


 


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值