Netbeans Maven Failed to execute goal on project

后端 未结 5 2094
小蘑菇
小蘑菇 2020-12-19 10:04

I am working on a java project currently, my problem is a bit weird as yesterday my code was working fine then suddenly today when I try to build and test my code I get this

相关标签:
5条回答
  • 2020-12-19 10:24

    I fixed the issue by updating to latest maven version, it started to use https instead of http to download all the deps.

    0 讨论(0)
  • 2020-12-19 10:25

    While the other responses give you workarounds by manually configuring the repository or a more recent version of Maven, the true source of the problem is that Netbeans (8.2) has became obsolete and is no more updated, you'd better migrate to Apache Netbeans (currently at version 11.3).

    0 讨论(0)
  • 2020-12-19 10:33

    The issue is related to maven moving to https only: https://blog.sonatype.com/central-repository-moving-to-https

    I have found that my problem was that Netbeans (8.2) was set to use the bundled maven executable (3.0.5). This version of maven is outdated and does not automatically reach for the https repo.

    I have a newer version installed (Apache Maven 3.5.4 (Red Hat 3.5.4-5) ) that worked by executing mvn clean install in my project's directory.

    To get Netbeans to use a different version of maven you can go to Tools->Options->Java->Maven and in Maven Home point to where your maven installation is located. For me it was /usr/bin/mvn and I had to define the path as just /usr as it seems that Netbeans expects to find a directory named bin containing the mvn executable.

    Also, related to maven moving repositories, for certain old dependencies I had to use the now insecure endpoint in my maven config:

            <pluginRepository>
                <id>Codehaus repository</id>
                <url>http://insecure.repo1.maven.org/maven2/</url>
            </pluginRepository> 
    

    Just adding this in case it is useful to anyone.

    0 讨论(0)
  • 2020-12-19 10:40
    <packaging>jar</packaging>
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    <repositories>
        <repository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    
    0 讨论(0)
  • 2020-12-19 10:46

    You should update your maven version, the last maven version use https.

    1. Download maven https://maven.apache.org/download.cgi (binary zip file) and extract it.
    2. In netbeans, go to Tools -> Options -> Java -> Maven. In Maven Home select Browse, and select the folder where you extract maven
    3. Enjoy it!
    0 讨论(0)
提交回复
热议问题