Maven构建错误 - 即使我不在代理网络中,也拒绝连接到maven中央存储库

时间:2016-01-27 07:03:41

标签: java maven

当我创建新的maven项目时,清理并构建它我收到此错误消息。

Scanning for projects...

------------------------------------------------------------------------
Building mavenproject6 1.0-SNAPSHOT
------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.pom

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 22.506s
Finished at: Wed Jan 27 12:26:55 IST 2016
Final Memory: 7M/123M
------------------------------------------------------------------------
Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from/to central (http://repo.maven.apache.org/maven2): Connection to http://repo.maven.apache.org refused: Connection timed out: connect -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

我尝试将maven-resources-plugin-2.5.jarmaven-resources-plugin-2.5maven-surefire-plugin-2.10.jarmaven-install-plugin-2.3.1.jar添加到 C:\ Users \ MI Synergy.m2 \ repository \ org \ apache \ maven \ plugins \ maven-resources-plugin \ 2.5 并输入命令mvn compile through cmd。

但它也不起作用。

已经有一个丢失的POM文件。

请帮我解决这个问题。我从几天开始尝试这个,并尝试了我能做的一切......

谢谢。

修改 我的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.exm</groupId>
<artifactId>mavenproject6</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>mavenproject6</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
      </project>

1 个答案:

答案 0 :(得分:1)

我没有遇到任何问题,我在清理安装时获得了成功

的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.exm</groupId>
  <artifactId>mavenproject6</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>mavenproject6</name>

  <properties>
      <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
      <dependency>
          <groupId>javax</groupId>
          <artifactId>javaee-web-api</artifactId>
          <version>6.0</version>
          <scope>provided</scope>
      </dependency>
  </dependencies>

  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>2.3.2</version>
              <configuration>
                  <source>1.6</source>
                  <target>1.6</target>
                  <compilerArguments>
                      <endorseddirs>${endorsed.dir}</endorseddirs>
                  </compilerArguments>
              </configuration>
          </plugin>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-war-plugin</artifactId>
              <version>2.1.1</version>
              <configuration>
                  <failOnMissingWebXml>false</failOnMissingWebXml>
              </configuration>
          </plugin>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-dependency-plugin</artifactId>
              <version>2.1</version>
              <executions>
                  <execution>
                      <phase>validate</phase>
                      <goals>
                          <goal>copy</goal>
                      </goals>
                      <configuration>
                          <outputDirectory>${endorsed.dir}</outputDirectory>
                          <silent>true</silent>
                          <artifactItems>
                              <artifactItem>
                                  <groupId>javax</groupId>
                                  <artifactId>javaee-endorsed-api</artifactId>
                                  <version>6.0</version>
                                  <type>jar</type>
                              </artifactItem>
                          </artifactItems>
                      </configuration>
                  </execution>
              </executions>
          </plugin>
      </plugins>
</build>
</project>

将以下内容添加到您的pom.xml

<repository>              
          <id>central</id>
          <name>Central</name>
          <url>http://repo1.maven.org/maven2</url>
</repository>

这里解决了类似的错误...

Maven Building Error - connection refused