问题描述
我在 SpringSource Tool Suite 中创建了一个新的 maven 项目.我在我的新 maven 项目中遇到了这个错误.
I have created a new maven project in SpringSource Tool Suite. I am getting this error in my new maven project.
传输失败org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 来自http://repo1.maven.org/maven2 已缓存在本地存储库中,直到更新间隔为中央已过期或强制更新.原始错误:无法转移神器org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to中央 (http://repo1.maven.org/maven2):连接超时
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.app</groupId>
<artifactId>TestApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TestApp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
设置.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">
<pluginGroups>
</pluginGroups>
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>user</username>
<password>pass</password>
<host>ip</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
</mirrors>
<profiles>
</profiles>
</settings>
请注意,我可以构建它.IDE 内的 pom.xml 中显示错误.有任何解决方案吗?
Please note that I am able to build it.Error is showing in pom.xml inside IDE .Any solutions?
推荐答案
使用以下 settings.xml
简化事情:
Simplify things by using the following 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">
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<username>user</username> <!-- Put your username here -->
<password>pass</password> <!-- Put your password here -->
<host>123.45.6.78</host> <!-- Put the IP address of your proxy server here -->
<port>80</port> <!-- Put your proxy server's port number here -->
<nonProxyHosts>local.net|some.host.com</nonProxyHosts> <!-- Do not use this setting unless you know what you're doing. -->
</proxy>
</proxies>
</settings>
在 Linux/Unix 下,将它放在 ~/.m2/settings.xml
下.在 Windows 下,将它放在 c:documents and settingsyouruser.m2settings.xml
或 c:usersyouruser.m2settings.xml
下.
Under Linux/Unix, place it under ~/.m2/settings.xml
. Under Windows place it under c:documents and settingsyouruser.m2settings.xml
or c:usersyouruser.m2settings.xml
.
您不需要 、
和
部分,除非您真的知道它们的用途.
You don't need the <mirrors/>
, <profiles/>
and <settings/>
sections, unless you really know what they're for.
这篇关于无法传输工件 org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central (http://repo1.maven.org/maven2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!