Maven settings 开源中国 镜像并下载本地仓库

本文介绍了如何配置Maven使用开源中国的China镜像,以提高国内用户下载速度并减少下载失败的可能性。通过设置Maven镜像、激活特定配置文件和创建本地仓库目录,读者可以轻松实现Maven的加速下载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如果还没配置好Maven的朋友请先配置好Maven,配置Maven点击:http://blog.youkuaiyun.com/icoudsoft_saas/article/details/50390873

Maven settings文件里面的配置的镜像默认是国外的,由于大天朝的原因呢,下载国外的东西是很慢的,并且很容易出现中断或者下载失败的原因,

基于这个原因呢,2012年,开源中国终于弄了个China镜像,方便国内的Maven使用者:

配置如下:


第一:

<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>  
			<id>nexus-osc</id>  
			<mirrorOf>central</mirrorOf>  
			<name>Nexus osc</name>  
			<url>http://maven.oschina.net/content/groups/public/</url>  
		</mirror>  
		<mirror>  
			<id>nexus-osc-thirdparty</id>  
			<mirrorOf>thirdparty</mirrorOf>  
			<name>Nexus osc thirdparty</name>  
			<url>http://maven.oschina.net/content/repositories/thirdparty/</url>  
			
			
		</mirror> 	
  </mirrors>

第二:

<profile>  
			<id>jdk-1.4</id>  
			<activation>  
				<jdk>1.4</jdk>  
			</activation>  
					
			<repositories>  
				<repository>  
					<id>nexus</id>  
					<name>local private nexus</name>  
					<url>http://maven.oschina.net/content/groups/public/</url>  
					<releases>  
						<enabled>true</enabled>  
					</releases>  
					<snapshots>  
						<enabled>false</enabled>  
					</snapshots>  
				  </repository>  
			</repositories>  
			  <pluginRepositories>  
				<pluginRepository>  
					<id>nexus</id>  
					<name>local private nexus</name>  
					<url>http://maven.oschina.net/content/groups/public/</url>  
					<releases>  
						<enabled>true</enabled>  
					</releases>  
					<snapshots>  
						<enabled>false</enabled>  
					</snapshots>  
				</pluginRepository>  
			  </pluginRepositories>  
		  </profile>  
		  <profile>  
			<id>osc</id>  
			<activation>  
				<activeByDefault>true</activeByDefault>  
			</activation>  
			<repositories>  
				<repository>  
					<id>osc</id>  
					  <url>http://maven.oschina.net/content/groups/public/</url>  
				</repository>  
				<repository>  
					<id>osc_thirdparty</id>  
					<url>http://maven.oschina.net/content/repositories/thirdparty/</url>  
				</repository>  
			  </repositories>  
			<pluginRepositories>  
				<pluginRepository>  
					<id>osc</id>  
					<url>http://maven.oschina.net/content/groups/public/</url>  
				  </pluginRepository>  
			</pluginRepositories>  
		  </profile>

第三:

创建本地仓库目录(目录必须事先建好)

<localRepository>本地仓库路径</localRepository>


然后打开dos命令:

执行:mvn help:system


坐等jar包下到本地仓库吧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值