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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35030759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 23:39:42  来源:igfitidea点击:

Maven build error - Connection to maven central repository refused even though I am not in proxy network

javamaven

提问by Search Results Web results Pi

When I created new maven project , clean and build it I get this error message.

当我创建新的 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

I tried to add maven-resources-plugin-2.5.jar, maven-resources-plugin-2.5, maven-surefire-plugin-2.10.jarand maven-install-plugin-2.3.1.jarto C:\Users\MI Synergy.m2\repository\org\apache\maven\plugins\maven-resources-plugin\2.5and enter the command mvn compile through cmd.

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

But it doesn't also work.

但它也不起作用。

There is a missing POM file which there is already.

缺少一个已经存在的 POM 文件。

Please help me with this. I'm trying this from days and tried everything I could do..

请帮我解决一下这个。我几天以来一直在尝试这个并尝试了我能做的一切..

Thank you.

谢谢你。

EditMy POM.XML

编辑我的 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>

采纳答案by Pratap A.K

I am not facing any issue, I am getting build success when I do clean install

我没有遇到任何问题,当我进行全新安装时,我获得了构建成功

pom.xml

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>

add below to your pom.xml

将下面添加到您的 pom.xml

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

Similar error resolved here...

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

Maven Building Error - connection refused

Maven 构建错误 - 连接被拒绝