Java spring boot pom.xml 传输失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49654666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 03:05:08  来源:igfitidea点击:

spring boot pom.xml Failure to transfer

javaspringmavenspring-bootpom.xml

提问by Omar Amaoun

I've just create a new spring boot projet and i have a probleme in the pom.xml and i have no idea how to resolve it, please some help, thanks for all.

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

the error in the the pom.xml it in the parent tag whitch is :

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

Project build error: Non-resolvable parent POM for com.example:ProjetTest:0.0.1-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.RELEASE from https://repo.maven.apache.org/maven2was 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.0.0.RELEASE from/to central (https://repo.maven.apache.org/maven2): Connection refused: connect and 'parent.relativePath' points at no local POM

项目构建错误: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>

采纳答案by kakabali

Things to try

尝试的事情

  1. You can try replacing your beginning <project>tag like below:-
  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>

  1. You need to remove <relativePath/>and the parent will look like below:-
  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>

  1. If still it is not resolving then it could be various things like:-

    1. internet connection, could be proxy issue also
    2. try deleting the folder M2_FOLDER_LOCATION\.m2\repository\org\springframework\boot\spring-boot-parentand then re importing the project.
  1. 如果仍然没有解决,那么它可能是各种各样的事情,例如:-

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

回答by Kevin Raoofi

relativePathrequires a path inside it like so:

relativePath需要一个路径,像这样:

<parent>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1</version>
  <relativePath>../parent/pom.xml</relativePath>
</parent>

All you likely need to do is remove <relativePath/>and make your parent look like so:

您可能需要做的就是删除<relativePath/>并让您的父母看起来像这样:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
</parent>

回答by pratyusha k

I was facing the same problem. I followed the following steps:

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

  1. Right-click on the project and select Maven,
  2. Click on Update Project,
  3. Except Offline select every checkbox.
  1. 右键单击项目并选择Maven,
  2. 点击更新项目,
  3. 除了离线选择每个复选框。

It should work fine now.

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