ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

eclipse和idea设置mave国内镜像

2020-11-28 12:00:09  阅读:234  来源: 互联网

标签:xml settings nexus eclipse idea mave maven osc


idea配置maven国内镜像

点击idea左上角file—>settings…
搜索maven将 右边Maven home directory框里面的路径该为自己的maven所在路径
勾选 User settings file 和Local repository后面框的Override
设置完成后点击Apply–>ok即可

eclipse设置mave国内镜像

打开eclipse后,window-》preferences-》maven
mac:eclipse偏好设置-》maven
然后选择 User Settings,如下图:
在这里插入图片描述
根据图中3的指示的位置,创建一个配置文件settings.xml。
linux/mac均可使用下面命令创建,先不写任何内容,然后保存,vim命令模式下是:wq,注:w是写入,q是退出,冒号是命令开始
~$ vim /home/joyven/.m2/settings.xml

    windows需要在当前用户目录下,依管理员身份创建。 

接着回到eclipse的操作步骤,先关闭preferences面板,再次根据前面说步骤的,打开此面板,你会看到User Settings中发生的变化,如下图:
在这里插入图片描述
多出来了一个openfile。点击openfile,然后Apply,再OK,最后关闭此面板。此时,已经在eclipse编辑窗口打开了前面创建的settings.xml文件。
在这里插入图片描述
将下面的代码复制到settings.xml文件中,保存即可。

<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<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>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>

	<profiles>
		<profile>
			<id>default</id>
			<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>
	</profiles>
</settings>

测试一下:在eclipse中创建一个maven工程,然后在eclipse的console窗口中,选择maven console。就可以看到加载的包的来源了。
在这里插入图片描述
右下角的倒三角箭头鼠标悬浮上去后,有很多console列表,选择maven console即,点击即可切换到maven窗口,可看到有关下载源的信息,如下图:
在这里插入图片描述
settings.xml文件中,在标签必须包含在中,否则在使用命令行执行mvn时,会出现一些错误:
Error reading settings.xml: Unrecognised tag: ‘profile’ (position: START_TAG seen …\n\n\t… @22:11)
Line: 22
Column: 11
joyven@joyven-ThinkPad-E450:/mnt/workspace/spring-mvc$ mvn archetype:generate DgroupId=joyven -DartifactId=spring-mvc -DarchetypeArtifactId=maven-archetype-webapp
修改之后则没有了。

标签:xml,settings,nexus,eclipse,idea,mave,maven,osc
来源: https://blog.csdn.net/lcecube/article/details/110262799

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有