[英]Getting error to import Spring boot parent into Pom.xml
我正在嘗試使用 maven 創建示例 Spring-Boot 項目,但是當我導入 Eclipse 時。 我在 Pom.xml 中收到關於 spring-boot 父級的錯誤,但是當我從終端運行 mvn 命令時。 它工作正常。 此外,在主 class 中,它無法識別 org.springframework.*
我收到一個錯誤,上面寫着
Project build error: Non-resolvable parent POM: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.3.0.RELEASE from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.3.0.RELEASE from/to central (http://repo.maven.apache.org/maven2): Failed to transfer http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.3.0.RELEASE/spring-boot-starter-parent-2.3.0.RELEASE.pom. Error code 501, HTTPS Required and 'parent.relativePath' points at wrong local POM
我的 Pom.xml 看起來像這樣
<?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.3.0.RELEASE</version>
<!-- <relativePath /> -->
</parent>
<groupId>com.test</groupId>
<artifactId>products</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>products</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.3.0.RELEASE</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.0.RELEASE</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Error code 501, HTTPS Required
- 此錯誤表明您正在嘗試使用HTTP
協議連接到 maven 中央存儲庫
從 2020 年初開始,maven 中央僅支持通過HTTPS
進行通信。 有關更多詳細信息,請參閱此頁面
驗證您的 maven 設置。 If you have configured maven central repository with http urls http://repo1.maven.org
or http://repo.maven.apache.org/
switch url to https
嘗試在 pom.xml 中添加存儲庫。 還要確保您有正確的互聯網連接,以便從 repo 下載依賴項。
<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</repository>
</repositories>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.