67

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

error

This is the complete POM file:

<?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>

9ilsdx 9rvj 0lo
  • 7,955
  • 10
  • 38
  • 77
Rômulo Sorato
  • 1,570
  • 5
  • 18
  • 29
  • https://github.com/Romulo-S/Manager-System – Rômulo Sorato May 20 '19 at 08:07
  • 1
    I ran into this same problem, it was [Bug 547340 - Cannot import any project into Eclipse with maven-jar-plugin 3.1.2](https://bugs.eclipse.org/bugs/show_bug.cgi?id=547340). SOLUTION: `Eclipse > Help > Install New Software > Work with= https://download.eclipse.org/m2e-wtp/signed/mavenarchiver/0.17.4/, , m2e extensions= Y > Next...` Updating m2e did *NOT* work. Manually installing m2e 0.17.4 *DID* work. – paulsm4 Oct 21 '19 at 03:24

9 Answers9

131

This seems like a bug in 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 properties section:

<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>

So your pom will look like this:

<?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.

gybandi
  • 1,880
  • 1
  • 11
  • 14
  • 1
    Thanks! By the way, how did you find that this is a bug? – Rômulo Sorato May 22 '19 at 05:17
  • 7
    @RomuloSorato no problem ;) I also use eclipse, so I created a dummy project to reproduce the issue, after creation I immediatly encountered the issue. Tried maven build and application run, it worked flawlessly, so I concluded it could be a bug in eclipse. I did a search for 'maven' in the eclipse bugzilla and found an issue that seemed similiar – gybandi May 22 '19 at 07:51
  • 1
    Thats nice! Thanks again. – Rômulo Sorato May 24 '19 at 01:32
  • 1
    No luck with the 'update' to m2e, running latest downloadable eclipse, with the m2e milestone 1.12.0.20190529-1915, and it still does't work – bluemind Jun 17 '19 at 13:44
  • 8
    Ah, it's the m2e-wtp, updating from this milestones download site made it work http://download.eclipse.org/m2e-wtp/milestones/1.4. You might want to add that in big letters :) – bluemind Jun 17 '19 at 14:00
14

Step 1:

Downgrade to <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 2 Update Project

  • Right Click on your Project
  • Go to Maven
  • Click on Update Project
  • Clean and Re-Run your Application

enter image description here


enter image description here

Romil Patel
  • 12,879
  • 7
  • 47
  • 76
  • 2
    The application runs fine,however, the error in line 1 persists – Rômulo Sorato May 20 '19 at 06:14
  • 1
    Do *NOT* downgrade anything. Eclipse "update" didn't help me, either. Instead, manually install the fix for Eclipse Bug 547340: `Eclipse > Help > Install New Software > Work with= https://download.eclipse.org/m2e-wtp/signed/mavenarchiver/0.17.4/, , m2e extensions= Y > Next...` – paulsm4 Oct 21 '19 at 03:31
7
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>

Add this dependency in pom.xml under properties tag

Tanmay Naik
  • 586
  • 1
  • 4
  • 16
4

For spring boot project I have added this:

<properties>
            <java.version>1.8</java.version>
            <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
        </properties>
double-beep
  • 5,031
  • 17
  • 33
  • 41
Avinash Khadsan
  • 441
  • 3
  • 6
  • 1
    While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. [From Review](/review/low-quality-posts/25753230) – double-beep Apr 02 '20 at 20:03
2

Was Getting exact same error. Solution by Gybandi kinda worked for me.

  • 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.

G.A.
  • 1,443
  • 2
  • 22
  • 34
  • 1
    you could also try Help > Install new software, select "All Available sites" from "Work with" combobox and type in m2e in search, then check in the "m2e connector for mavenarchiver pom properties" under m2e extensions – gybandi Jun 12 '19 at 14:22
  • @gybandi thanks! Sadly I have the same problem as G.A.. Of course downgrading to v3.1.1 worked, but I would like not to have to do that. Now when I try to check for updates, it says there are none. Trying to get it from the Eclipse Market does not get me further either. I am using Eclipse Version: 2019-03 (4.11.0), Build id: 20190314-1200. I'll give Eclipse 2019-06 RC1 since I have some time on my hands. – Igor Jun 14 '19 at 21:59
  • @Igor have you tried "Install new software" section instead of the Eclipse Marketplace/Check for updates? Sometimes marketplace does not work for me neither – gybandi Jun 16 '19 at 07:26
  • @gybandi I actually did not try the Marketplace - just "Install New Software" from the Help-menu... weird... No proxy (since it was from my home PC) either... – Igor Jun 17 '19 at 12:41
2

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

Khaled Jamal
  • 628
  • 1
  • 6
  • 18
2

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.

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

https://download.eclipse.org/technology/m2e/releases/1.13/

this worked like a charm

Ravikiran butti
  • 1,668
  • 2
  • 11
  • 18
2

Adding packaging tag solved my problem. Didn't need to lower maven-jar plugin version.

<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>
0

I fixed this issue by changing the version from 2.1.6 to 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

.m2\repository\org\springframework\boot\spring-boot-starter-parent

RArora
  • 234
  • 1
  • 7