[英]Java Maven Spring Could not transfer artifact org.apache.maven.surefire:surefire-junit-platform:pom:2.22.2 from/to central
Java Spring project fails to package the project with maven, printing the following error: Java Spring 项目无法 package 项目出现 Z402C5D9AF6B43711EA070BEE5D7 打印错误:
Could not transfer artifact org.apache.maven.surefire:surefire-junit-platform:pom:2.22.2 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom
The use used pom: pom的使用:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>***</groupId>
<artifactId>***</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>***</name>
<description>***</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I use IntelliJ to develop and build the project.我使用 IntelliJ 开发和构建项目。 I do not need a proxy to enter the internet.我不需要代理即可进入互联网。 If I click the link, I can see the pom file without problems.如果我点击链接,我可以毫无问题地看到 pom 文件。 Reloading the project does not work, downloading all sources neither.重新加载项目不起作用,也不能下载所有源。
In the local storage, I find the following files:在本地存储中,我找到以下文件:
C:\Users\***\.m2\repository\org\apache\maven\plugins\maven-surefire-plugin\2.22.2
_remote.repositories
maven-surefire-plugin-2.22.2.jar
maven-surefire-plugin-2.22.2.jar.sha1
maven-surefire-plugin-2.22.2.pom
maven-surefire-plugin-2.22.2.pom.sha1
Removing them and reloading the project restores the files, the error persists.删除它们并重新加载项目会恢复文件,错误仍然存在。
I cleaned the project and used the -Dhttps.protocols=TLSv1.2
parameter no changes.我清理了项目并使用-Dhttps.protocols=TLSv1.2
参数没有变化。
Edit:编辑:
Using a VPN doe not work.使用 VPN 不起作用。
Output of mvn -v
: mvn -v
的 Output :
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Program Files\java\apache-maven-3.8.4
Java version: 1.8.0_312, vendor: Temurin, runtime: C:\Program Files\Eclipse Adoptium\jdk-8.0.312.7-hotspot\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
When building with mvn clean package -U
:使用mvn clean package -U
构建时:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project Grafnus-Server: Unable to generate classpath: org.apache.maven.artifact.resolver.ArtifactResolutionException: Unable to get dependency information for org.apache.maven.surefire:surefire-junit-platform:jar:2.22.2: Failed to retrieve POM for org.apache.maven.surefire:surefire-junit-platform:jar:2.22.2: Could not transfer artifact org.apache.maven.surefire:surefire-junit-platform:pom:2.22.2 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom
[ERROR] from the specified remote repositories:
[ERROR] central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false)
[ERROR] Path to dependency:
[ERROR] 1) dummy:dummy:jar:1.0
The issue was the outdated java version.问题是过时的 java 版本。 I updated to a newer one and at first I did not change it in the project settings (thought that would change on his own).我更新了一个更新的,起初我没有在项目设置中更改它(以为他会自己改变)。 Now it works like a charm.现在它就像一个魅力。 Thanks to @khmarbaise感谢@khmarbaise
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.