如何在NetBeans IDE中将Maven的远程存储库URL更改(从http更改为https)? [英] How to change maven's Remote Repository URL in the NetBeans IDE (from http to https)?

查看:284
本文介绍了如何在NetBeans IDE中将Maven的远程存储库URL更改(从http更改为https)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试运行NetBeans项目时,出现以下错误消息:

When trying to run a NetBeans project, I get the following error message:

无法执行目标 org.apache.maven.plugins:maven-surefire-plugin:2.10:test (默认测试)在项目MyNetBeansProject上:目标的执行默认测试 org.apache.maven.plugins:maven-surefire-plugin:2.10:test失败: 插件org.apache.maven.plugins:maven-surefire-plugin:2.10或以下之一 无法解决其依存关系:无法收集依存关系 对于org.apache.maven.plugins:maven-surefire-plugin:jar:2.10():失败 读取文物描述符 org.apache.maven.surefire:surefire-booter:jar:2.10:无法传输 工件org.apache.maven.surefire:surefire-booter:pom:2.10 from/to 中央( http://repo.maven.apache.org/maven2 ):传输失败 文件: http: //repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.10/surefire-booter-2.10.pom . 返回码是:501,ReasonPhrase:HTTPS必需. -> [帮助1]

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project MyNetBeansProject: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.10 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-surefire-plugin:jar:2.10 (): Failed to read artifact descriptor for org.apache.maven.surefire:surefire-booter:jar:2.10: Could not transfer artifact org.apache.maven.surefire:surefire-booter:pom:2.10 from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.10/surefire-booter-2.10.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]

错误消息的以下部分是最重要的部分:

The following part of the error message is the most important one:

无法传输文件: http: //repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.10/surefire-booter-2.10.pom . 返回码是:501,ReasonPhrase:HTTPS必需.

Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.10/surefire-booter-2.10.pom. Return code is: 501 , ReasonPhrase:HTTPS Required.

服务-> Maven存储库->中央存储库->右键单击中央存储库"会提供以下信息:

Services -> Maven Repositories -> Central Repository -> right mouse click on "Central Repository" gives the following information:

可以看到,远程存储库URL是" http://repo.maven.apache .org/maven2/".我认为应该改为" https://repo.maven.apache.org/maven2/". 但是,问题是我似乎无法更改远程存储库URL.

As one can see, the Remote Repository URL is "http://repo.maven.apache.org/maven2/". I think it should instead be "https://repo.maven.apache.org/maven2/". However, the problem is that I can't seem to change the Remote Repository URL.

有人知道如何在NetBeans IDE中更改Maven的远程存储库URL吗?

Does anybody know how to change maven's Remote Repository URL in the NetBeans IDE?

更新:

在NetBeans->首选项下,可以看到我的NetBeans IDE使用的Maven版本是版本3.0.5:

Under NetBeans -> Preferences one can see that the maven version used by my NetBeans IDE is Version 3.0.5:

推荐答案

我认为您有三个选择.

您可以迁移到Netbeans 11.0 LTS(或11.2),它使用内置的Maven 3.3.9版本.它已经使用了https.

You can migrate to Netbeans 11.0 LTS (or 11.2), it uses a built-in Maven 3.3.9 version. It already uses https.

您可以继续使用Netbeans 8.2,但可以下载独立的apache maven,将其安装到系统中,然后在 Options-> Java-> Maven-> Maven Home中将新的maven主目录设置为路径.

You can stay with Netbeans 8.2 but download standalone apache maven, install it to your system and set the path to the new maven home directory in Options -> Java -> Maven -> Maven Home.

您只需要:

  1. Download apache-maven-3.6.3-bin.zip (or apache-maven-3.6.3-bin.tar.gz) from Apache
  2. Unzip it to any directory. It will be the Maven home.
  3. Set the Maven home directory in NetBeans to the directory where you have extracted zip file.
  4. Ensure than you have set JAVA_HOME in your environment variables

有关如何安装独立版本的说明此处.

Instructions how to install standalone version here.

如果在NetBeans中正确设置了Maven Home,它将显示更新的版本:

If you set the Maven Home in NetBeans correctly it will show you updated version:

只需使用https将存储库添加到pom.xml中(例如像这样)

Just add repositories into your pom.xml with https (for example like that)

<repositories>
        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
        </repository>
    </repositories>
<pluginRepositories>
    <pluginRepository>
        <releases>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>Central Repository</name>
        <url>https://repo.maven.apache.org/maven2</url>
    </pluginRepository>
</pluginRepositories>

Maven Central迁移到https

问题来自 :

从2020年1月15日起,中央存储库不再支持 通过HTTP进行的不安全通信,并且要求对 存储库通过HTTPS加密.

As of January 15, 2020, The Central Repository no longer supports insecure communication over HTTP and requires that all requests to the repository are encrypted over HTTPS.

这是已解决的相关改进和相关的

Here is the relevant improvement that was resolved and relevant changes.

这篇关于如何在NetBeans IDE中将Maven的远程存储库URL更改(从http更改为https)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆