简体   繁体   English

将 Spring 引导父级导入 Pom.xml 时出错

[英]Getting error to import Spring boot parent into Pom.xml

I am trying to create a sample Spring-Boot project using maven but when i imported into Eclipse.我正在尝试使用 maven 创建示例 Spring-Boot 项目,但是当我导入 Eclipse 时。 I am getting an error in Pom.xml about spring-boot parent but when i run mvn command from terminal.我在 Pom.xml 中收到关于 spring-boot 父级的错误,但是当我从终端运行 mvn 命令时。 It works fine.它工作正常。 Also, in main class, it does not recognize org.springframework.*此外,在主 class 中,它无法识别 org.springframework.*

I am getting an error which says that我收到一个错误,上面写着

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

My Pom.xml looks like this我的 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 - this error indicates that you are trying to connect to maven central repository using HTTP protocol Error code 501, HTTPS Required - 此错误表明您正在尝试使用HTTP协议连接到 maven 中央存储库

From beginning of 2020, maven central supports communication over HTTPS only.从 2020 年初开始,maven 中央仅支持通过HTTPS进行通信。 See this page for more details有关更多详细信息,请参阅此页面

Verify your maven settings.验证您的 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 If you have configured maven central repository with http urls http://repo1.maven.org or http://repo.maven.apache.org/ switch url to https

Try adding repository in pom.xml.尝试在 pom.xml 中添加存储库。 Also make sure you have proper internet connection so that dependencies will get downloaded from repo.还要确保您有正确的互联网连接,以便从 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM