spring boot pom.xml 传输失败

Oma*_*oun 6 java spring pom.xml maven spring-boot

我刚刚创建了一个新的 spring boot projet,我在 pom.xml 中有一个问题,我不知道如何解决它,请帮忙,谢谢大家。

父标签中的 pom.xml 中的错误是:

项目构建错误:com.example:ProjetTest:0.0.1-SNAPSHOT 的不可解析父 POM:无法从https:/传输 org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.RELEASE /repo.maven.apache.org/maven2已缓存在本地存储库中,在central 的更新间隔已过或强制更新之前不会重新尝试解析。原始错误:无法传输工件 org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.RELEASE from/to central ( https://repo.maven.apache.org/ maven2):连接被拒绝: 连接和 'parent.relativePath' 指向没有本地 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>Ticketing</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Ticketing</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.restdocs</groupId>
            <artifactId>spring-restdocs-mockmvc</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>
Run Code Online (Sandbox Code Playgroud)

kak*_*ali 16

尝试的事情

  1. 您可以尝试替换您的开始<project>标签,如下所示:-

<?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
            http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <!-- Other stuff of the pom.xml here -->
</project>
Run Code Online (Sandbox Code Playgroud)

Run Code Online (Sandbox Code Playgroud)

  1. 您需要删除<relativePath/>,父项将如下所示:-

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <!-- use your specific version here -->
    <version>2.0.0.RELEASE</version>
</parent>
Run Code Online (Sandbox Code Playgroud)

Run Code Online (Sandbox Code Playgroud)

  1. 如果仍然没有解决,那么它可能是各种各样的事情,例如:-

    1. 互联网连接,也可能是代理问题
    2. 尝试删除文件夹M2_FOLDER_LOCATION\.m2\repository\org\springframework\boot\spring-boot-parent,然后重新导入项目。


小智 6

我面临同样的问题。我按照以下步骤操作:

  1. 右键单击项目并选择Maven,
  2. 点击更新项目,
  3. 除了离线选择每个复选框。

现在应该可以正常工作了。