简体   繁体   English

spring boot pom.xml 传输失败

[英]spring boot pom.xml Failure to transfer

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/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced.项目构建错误: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 的更新间隔已过或强制更新之前不会重新尝试解析。 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原始错误:无法传输工件 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>

Things to try尝试的事情

  1. You can try replacing your beginning <project> tag like below:-您可以尝试替换开始的<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:-您需要删除<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-parent and then re importing the project.尝试删除文件夹M2_FOLDER_LOCATION\\.m2\\repository\\org\\springframework\\boot\\spring-boot-parent然后重新导入项目。

I was facing the same problem.我面临同样的问题。 I followed the following steps:我按照以下步骤操作:

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

It should work fine now.现在应该可以正常工作了。

relativePath requires 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>

I was practicing in home, so no proxy with one ISP, it was causing a problem but it was not before in any project for practice only.我在家里练习,所以没有代理与一个 ISP,这导致了一个问题,但之前在任何项目中都没有,仅供练习。 So deleted the setting.xml in .m2 folder (in windows os).因此删除了 .m2 文件夹中的 setting.xml(在 Windows 操作系统中)。 parent error in pom.xml disappeared pom.xml 中的父错误消失了

In my case it was a internet proxy issue.就我而言,这是一个互联网代理问题。

This might be a problem with the internet proxy as well.这也可能是 Internet 代理的问题。 Check your internet proxy settings.检查您的 Internet 代理设置。 Somehow MAVEN is not able to download the dependencies because of proxy.不知何故,由于代理,MAVEN 无法下载依赖项。

If you are using proxy, then follow steps mentioned in below link https://maven.apache.org/guides/mini/guide-proxies.html如果您使用代理,请按照以下链接中提到的步骤https://maven.apache.org/guides/mini/guide-proxies.html

I have used below configuration to make it work.我使用了以下配置来使其工作。

<settings>
<proxies>
    <proxy>
      <id>proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <!--
      <username>....</username>
      <password>....</password>
      -->
      <host>proxy.abcd.com</host>
      <port>1234</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
   </proxies>
</settings>

I also face same issue with the author, I use proxy and I have a storage to save all the maven dependency, so in the maven configuration I have set the maven to download from the storage I have made.我也面临着与作者相同的问题,我使用代理并且我有一个存储来保存所有 maven 依赖项,因此在 maven 配置中,我将 maven 设置为从我制作的存储中下载。 But I still face that problem.但我仍然面临这个问题。 Do you guys have any workarounds?大家有什么解决办法吗?

I use vscode and I have installed Java plugins for sure.我使用 vscode 并且我已经安装了 Java 插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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