Java Eclipse 显示“Maven 配置问题:未知”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/56212981/
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
Eclipse showing "Maven Configuration Problem: Unknown"
提问by R?mulo Sorato
I just imported a spingboot project that I created in https://start.spring.io/in eclipse. I tried to import two times, but the problem persists. Already tried to do a mvn update , a mvn clean install, tried to clean the project but none of this worked. Its a problem in the first line of pom xml file. I dont have any idea how to solve this. I'm using java 11
我刚刚在 eclipse 中导入了我在https://start.spring.io/中创建的 spingboot 项目。我尝试导入两次,但问题仍然存在。已经尝试进行 mvn update , mvn 全新安装,尝试清理项目,但这些都不起作用。这是 pom xml 文件第一行的问题。我不知道如何解决这个问题。我正在使用 Java 11
This is the complete POM file:
这是完整的 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.in28minutes.springboot.rest.example</groupId>
<artifactId>spring-boot-2-jpa-with-hibernate-and-h2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-2-jpa-with-hibernate-and-h2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</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>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
采纳答案by gybandi
This seems like a bug in eclipse: https://bugs.eclipse.org/bugs/show_bug.cgi?id=547340
这似乎是 Eclipse 中的一个错误:https: //bugs.eclipse.org/bugs/show_bug.cgi?id=547340
You can fix this by temporary downgrading the maven jar plugin version to 3.1.1 from 3.1.2. Add this to the propertiessection:
您可以通过将 Maven jar 插件版本从 3.1.2 临时降级到 3.1.1 来解决此问题。将此添加到属性部分:
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
So your pom will look like this:
所以你的 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.in28minutes.springboot.rest.example</groupId>
<artifactId>spring-boot-2-jpa-with-hibernate-and-h2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-2-jpa-with-hibernate-and-h2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</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>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Update:A fix has been released. Click Help > Check for updates in Eclipse/STS and install the newest m2e connector.
更新:已发布修复程序。单击帮助 > 检查 Eclipse/STS 中的更新并安装最新的 m2e 连接器。
回答by Patel Romil
Step 1:
第1步:
Downgrade to <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
降级到 <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<properties>
<java.version>X</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
Step 2Update Project
步骤 2更新项目
- Right Click on your Project
- Go to Maven
- Click on Update Project
- Clean and Re-Run your Application
- 右键单击您的项目
- 前往 Maven
- 点击更新项目
- 清理并重新运行您的应用程序
回答by G.A.
Was Getting exact same error. Solution by Gybandi kinda worked for me.
得到完全相同的错误。Gybandi 的解决方案对我有用。
Updating project in Maven> menu does nothing to make error icon go away.
Did the 3.1.1 and then did a maven -> update project from context menu. The red (x) icon is now GONE:-). But I really don't want to downgrade my maven plugin, if possible.
The suggestion of updating m2e-connector from eclipse marketplace does not work. All I see against the m2e-connector entry is a "learn more" link which takes me to its webpage. Nothing like "upgrade/update" button present.
在 Maven> 菜单中更新项目不会使错误图标消失。
做了 3.1.1,然后做了一个 maven -> 从上下文菜单更新项目。红色 (x) 图标现在消失了:-)。但如果可能的话,我真的不想降级我的 Maven 插件。
从 eclipse 市场更新 m2e-connector 的建议不起作用。我在 m2e-connector 条目中看到的只是一个“了解更多”链接,它将我带到它的网页。没有像“升级/更新”按钮那样的东西。
回答by Tanmay Naik
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
Add this dependency in pom.xml under properties tag
在属性标签下的 pom.xml 中添加此依赖项
回答by Khaled Jamal
if you are using spring boot downgrade the version to 2.1.4.RELEASE
instead of 2.1.5.RELEASE
it will solve the problem
如果您使用 spring boot 将版本降级为2.1.4.RELEASE
而不是2.1.5.RELEASE
它将解决问题
回答by RArora
I fixed this issue by changing the version from 2.1.6 to 2.1.3
我通过将版本从 2.1.6 更改为 2.1.3 来解决此问题
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
I changed this to 2.1.3 because there were two versions were shown available in local m2 repository at below path
我将其更改为 2.1.3,因为在以下路径的本地 m2 存储库中显示了两个可用版本
.m2\repository\org\springframework\boot\spring-boot-starter-parent
.m2\repository\org\springframework\boot\spring-boot-starter-parent
回答by Ravikiran butti
I am using eclipse photon and had similar issue. Didnt want to add the maven-jar-plugin.version in my pom as I dont want my codebase to contain code specific to IDE.
我正在使用 eclipse photon 并且遇到了类似的问题。不想在我的 pom 中添加 maven-jar-plugin.version,因为我不希望我的代码库包含特定于 IDE 的代码。
What I noticed is eclipse photon has m2e version of 1.5 which is causing the problem. I uninstall all the m2e connectors, restarted my eclipse and then installed the m2e connector using the below url manually
我注意到 eclipse photon 的 m2e 版本为 1.5,这导致了问题。我卸载了所有的 m2e 连接器,重新启动了我的 eclipse,然后使用下面的 url 手动安装了 m2e 连接器
https://download.eclipse.org/technology/m2e/releases/1.13/
https://download.eclipse.org/technology/m2e/releases/1.13/
this worked like a charm
这就像一个魅力
回答by Rohan Patil
Adding packaging tag solved my problem. Didn't need to lower maven-jar plugin version.
添加包装标签解决了我的问题。不需要降低 maven-jar 插件版本。
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/>
</parent>
回答by Avinash Khadsan
For spring boot project I have added this:
对于 spring boot 项目,我添加了这个:
<properties>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>