gpt4 book ai didi

java - 具有本地文件依赖的Maven项目构建错误501

转载 作者:行者123 更新时间:2023-12-01 18:25:07 25 4
gpt4 key购买 nike

我有一个带有本地依赖项的 Maven 项目,该项目无法编译,因为 maven 引入了这个“改进”:

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

这是我的 pom.xml:

...
<repositories>
<repository>
<id>in-project</id>
<name>In Project Repo</name>
<url>file://${project.basedir}/libs</url>
</repository>
</repositories>
...

所以现在我收到以下编译错误:

Could not resolve dependencies for project ........:war:1.0: Failed to
collect dependencies for [.........:jar:1.0 (compile),
javax:javaee-web-api:jar:7.0 (provided), .........:jar:1.0
(compile)]: Failed to read artifact descriptor for
.........:jar:1.0: Could not transfer artifact
.........:pom:1.0 from/to central
(http://repo.maven.apache.org/maven2): Failed to transfer file:
http://repo.maven.apache.org/maven2/com/..../..../1.0/.....-1.0.pom.
Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]

如您所见,我正在使用本地 jar 文件,但这不再编译

有人知道如何配置本地存储库以成功编译吗?

最佳答案

Maven 服务器不再支持 HTTP。您必须在本地 Maven 配置文件(位于您的主文件夹 yourname/.m2/settings.xml 中)中使用 HTTPS url 配置 Maven 存储库。

以下是您可以复制的示例:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>https://repo1.maven.org/maven2/</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>https://repo1.maven.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>

关于java - 具有本地文件依赖的Maven项目构建错误501,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60240927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com