Java SpringBoot中不可解析的父POM

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51672309/
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-11 00:11:49  来源:igfitidea点击:

Non-resolvable parent POM in SpringBoot

javaspringmavenspring-bootpom.xml

提问by Kshitiz Sharma

I am trying to setup a Maven project for a Spring Boot application but while trying to save the pom.xml file I am getting this following issue:

我正在尝试为 Spring Boot 应用程序设置一个 Maven 项目,但是在尝试保存 pom.xml 文件时,我遇到了以下问题:



Project build error: Non-resolvable parent POM for
io.javabrains.springbootquickstart:course-api:0.0.1-SNAPSHOT: Could not find artifact
org.springframework.boot:spring-boot-starter-parent:pom:${revision} in central (https:// repo.maven.apache.org/maven2) and 'parent.relativePath' points at wrong local POM

项目构建错误:
io.javabrains.springbootquickstart:course-api:0.0.1-SNAPSHOT的不可解析父POM :找不到工件
org.springframework.boot:spring-boot-starter-parent:pom:${revision}在中央 (https://repo.maven.apache.org/maven2) 和 'parent.relativePath' 指向错误的本地 POM

Here is my pom.xml file:

这是我的 pom.xml 文件:

<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>io.javabrains.springbootquickstart</groupId>
  <artifactId>course-api</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <name>Java Api course</name>


 <parent>
    <!-- Your own application should inherit from spring-boot-starter-parent -->
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.2 RELEASE</version>
  </parent>



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

采纳答案by Kshitiz Sharma

Solved the issue. There was a little mistake. It should be 1.4.2.RELEASEinstead of 1.4.2 RELEASE. There should not be space between RELEASE and 2. This little dot was causing the issue.

解决了这个问题。有一个小错误。它应该是1.4.2.RELEASE而不是1.4.2 RELEASERELEASE 和 2之间不应有空格。这个小点导致了这个问题。

回答by Alien

From where revision will be replaced ?

从哪里修订将被替换?

Modify pom.xmlby specifying any version like below.

pom.xml通过指定如下所示的任何版本进行修改。

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

回答by davidxxx

Here :

这里 :

<parent>
  <!-- Your own application should inherit from spring-boot-starter-parent -->
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>${revision}</version>
</parent>

${revision}will be interpolated by Maven (that is translated) only if Maven finds a variable with the revisionname.
But revisionis not a Maven built in variables. While variables as ${project.version}and ${project.artifactId}are.

${revision}仅当 Maven 找到具有revision名称的变量时,Maven 才会插入(即翻译)。
revision不是 Maven 内置变量。虽然变量${project.version}${project.artifactId}是。

So in your case, you have to declare or pass the variable explicitly if you want to use it.

所以在你的情况下,如果你想使用它,你必须显式声明或传递变量。

For example it could work by adding it :

例如,它可以通过添加它来工作:

<properties>
  <revision>1.4.2 RELEASE</revision>
</properties>

Or by running maven such as : mvn package -Drevision="1.4.2 RELEASE"

或者通过运行 maven,例如: mvn package -Drevision="1.4.2 RELEASE"

You can find more information here.

您可以在此处找到更多信息。

Note that a revisionproperty appears to have a too broad meaning and doesn't help to understand the property meaning.
A more precise name such as ${spring-boot-version}would make more sense.

请注意,revision属性的含义似乎过于宽泛,无助于理解属性的含义。
一个更精确的名字,比如${spring-boot-version}会更有意义。

回答by Niraj Jha

This may be because of spring initializer created project pom file like this

这可能是因为 spring 初始化程序创建了这样的项目 pom 文件

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

However, sts is compatible with version "2.0.4.RELEASE", just make this change

但是,sts 与版本“2.0.4.RELEASE”兼容,只需进行此更改

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

further Maven -> Update Project

进一步 Maven -> 更新项目

回答by lilalinux

Check your Proxy Settings. In case you are working with a company PC that already has Proxys configured for browsers but not yet for your IDE or maven, you could probably enter the same information as for your browsers. You can find them e.g. by opening the network settings of your browser -> LAN Settings and then download the proxy.pac file from the address given in the input field. That file is human readable.

检查您的代理设置。如果您使用的公司 PC 已经为浏览器配置了代理,但尚未为您的 IDE 或 maven 配置代理,您可能可以输入与浏览器相同的信息。例如,您可以通过打开浏览器的网络设置 -> LAN 设置,然后从输入字段中给出的地址下载 proxy.pac 文件来找到它们。该文件是人类可读的。

After that, you might still need to handle SSL errors by either

之后,您可能仍需要通过以下任一方式处理 SSL 错误

回答by nandini

Replace

代替

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

with

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

回答by Anurag Litoriya

For me, actually AntiVirus was working in my system. So, I have disabled that for an hour and changed my version to 2.0.4.RELEASE and it works for me.

对我来说,实际上 AntiVirus 正在我的系统中工作。所以,我已经禁用了一个小时并将我的版本更改为 2.0.4.RELEASE 并且它对我有用。