137

I'm facing an error in my pom.xml file given below:

Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found

Below is my pom.xml :

 <?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 https://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.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>dev.che</groupId>
    <artifactId>stu</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>stu</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</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>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

How can I fix this error?

Anish B.
  • 9,111
  • 3
  • 21
  • 41
Lakma Chehani
  • 1,415
  • 2
  • 6
  • 5

24 Answers24

354

I fixed the problem adding the version of the plugin in the pom.xml, which is the same of spring boot's version. (and it's working since spring boot 2.2 until 2.7.X)

So you just have to configure your pom like this:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${project.parent.version}</version>
</plugin>
Wagner Büttner
  • 3,799
  • 1
  • 13
  • 12
  • 1
    No !! You don't have to add this version tag. Spring boot projects can automatically handle plugin version – Anish B. Mar 27 '21 at 06:06
  • 52
    It can. But somehow is not working. That's why this post exists – Wagner Büttner Mar 27 '21 at 22:45
  • 5
    i have got this problem in IDEA 2021.2. But i have'nt the problem in earliest versions. Interesting – Zhenyria Aug 17 '21 at 18:45
  • 15
    I added `${project.parent.version}` and then removed and it is now working with IntelliJ. – OSGI Java Sep 29 '21 at 20:38
  • Yes, this is what it was said above. But nice that worked for you =) – Wagner Büttner Sep 30 '21 at 19:46
  • @AnishB. You are right, but this seem to be the only option if you don't want to keep looking at the ugly red color in IntelliJ. For other maven plugins you may use variables, but for `spring-boot-maven-plugin` you cannot! In `spring-boot-dependencies-2.5.5.pom`, all the plugins in `` have variables for their version, such as `${maven-surefire-plugin.version}`, but for some cryptic reason `spring-boot-maven-plugin` has hardcoded `2.5.5`. – Honza Zidek Oct 05 '21 at 11:50
  • Good @HonzaZidek, so just keep this code as suggested as in this topic for now =) – Wagner Büttner Oct 11 '21 at 15:47
  • 5
    this solution worked for me in idea 2022.1 – gdogra Feb 12 '22 at 13:00
  • 1
    this removed the error but normally the spring-boot-maven-plugin version doesn't have to be specified when using spring-boot-starter-parent https://docs.spring.io/spring-boot/docs/2.4.0/maven-plugin/reference/htmlsingle/ – velocity Aug 23 '22 at 22:06
60

i fixed the problem adding a version of the plugin in the pom.xml

<version>${project.parent.version}</version>
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Salim Nadji
  • 715
  • 5
  • 5
33

The pom.xml is correct. It seems that there is a network issue. The plugin was not downloaded due to that.

Steps to solve the issue :

  • Check for network issue. You need to have a strong internet connection to download all the dependencies and plugins using maven. Otherwise, you will face issue to build maven project for sure.

  • For eclipse/STS :

    1. Right click on the project >> Run As >> Maven clean (this will clean the project by deleting the target folder).

      Example :

enter image description here

  1. Right click on the project >> Run As >> Maven install (this will download all dependencies and generate target folder).

Example :

enter image description here

  1. If problem still persists, then last option is to force refresh of the project. Right click on the project >> Maven >> Update Project.

enter image description here

  1. Update Maven Project Window will be come.

enter image description here

Note: Enable the option Force update of Snapshot/Releases (look in above screenshot). By default, this option is not enabled. Click on ok. It will start updating.


  • For Intellij IDE :
  1. Open the Maven tab present on the right tab and check for spring-boot-maven-plugin.

enter image description here

  1. If the plugin was not downloaded, then click on clean maven lifecycle and it delete the folders that were generated by maven.

enter image description here

  1. Then, click on install maven lifecycle and it will download all the dependencies and generate all the folders from scratch required for the project.

enter image description here

  1. Last step is to force update of the project. You need to click on the Generate Sources and Update Folders for All Projects option.

enter image description here

Note : Go the Preference -> Build, Execution and Deployment -> Build Tools -> Maven -> Enable "Always update Snapshots" option present -> Click on Apply and Ok. This option helps sometimes.


  • For Without any IDE :
  1. Download maven from here and extract it.

  2. Set maven location on the environment variable so that it can run from anywhere.

  3. Open CMD/Terminal and then do mvn clean install inside the project.


Update for viewers: <version> tag is not mandatory tag to be there for spring-boot projects because pom.xml created by spring for spring-boot can handle the version of the spring-boot-maven-plugin.

Updated pom.xml :

<?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 https://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.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>dev.che</groupId>
    <artifactId>stu</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>stu</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</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>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Edit :

If above steps are not solving your issue, then you can go for the workaround solution by explicitly providing the parent spring boot version in the plugin for spring-boot-maven-plugin (not a recommended solution):

<plugins>
   <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <version>${parent.version}</version> 
    </plugin>
</plugins>
Anish B.
  • 9,111
  • 3
  • 21
  • 41
  • 2
    '''mvn clean install''' worked for me! I had to download Maven too from [Here](https://maven.apache.org/download.cgi) and I also followed [This YouTube video](https://www.youtube.com/watch?v=--Iv5vBIHjI) – BpY Jan 01 '21 at 20:47
  • 2
    It did not work for me. Unfortunately (I am **not** happy with the solution!) only https://stackoverflow.com/a/66824948/2886891 worked. – Honza Zidek Oct 05 '21 at 14:42
  • @HonzaZidek It should work. I gave this solution with testing only. I don't know why it's not working for you. – Anish B. Oct 05 '21 at 14:50
  • @HonzaZidek Actually, Intellij is good when it comes to gradle projects but not with maven projects. I use maven projects with eclipse for most of time. Anyways, Intellij can handle maven projects but you need to know proper settings to use maven effectively. – Anish B. Oct 05 '21 at 14:54
  • @AnishB If I run `mvn clean install` and Maven is happy without warnings, I expect the same result from IntelliJ IDEA. `spring-boot-maven-plugin` is in spring-boot ``, so the version should not be required. However, IDEA is unhappy. This should work out of the box, not "know proper settings" should be needed :( So I **had** to go for the workaround solution with `${project.parent.version}`, even if I don't like it. And BTW, `${parent.version}` produces another warning... – Honza Zidek Oct 05 '21 at 17:10
  • 2
    `${parent.version}` is work for me – TopekoX May 02 '22 at 11:25
  • 1
    This should be marked as answer. Much more complete and still working. – Shad Jul 29 '22 at 18:25
  • 1
    Worked, thank you!. If you have mvn wrapper, you can do ./mvnw clean install – nicolass Sep 01 '22 at 12:45
13

This solution worked for me:

From the Preferences in Intelli J, navigate to "Build, Execution, Deployment > Build Tools > Maven", check the "Use plugin registry", and click "OK".

Then "File > Invalidate Caches / Restart" to reload Intelli J. The error will go away automatically.

I just followed these steps in IntelliJ IDEA:

Click File from menu and then click Invalidate Caches / Restart.

aylingumus
  • 189
  • 2
  • 6
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/30157451) – Balaji Oct 23 '21 at 14:56
  • I've included the essential parts of the answer by providing link and by quoting. Thanks for informing. – aylingumus Oct 23 '21 at 15:28
  • 1
    Tried it. Didn't work for me. – Sameer Patel Mar 11 '22 at 15:58
7

I encountered this issue in January 2022 when the version changed to 2.6.3. I lowered the version of the project to 2.6.2 as well but was unsuccessful. However adding the following line <version>${project.parent.version}</version> plugins solves the issue regardless of the version. The snippet is given below

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${project.parent.version}</version>
</plugin>
PKS
  • 618
  • 1
  • 7
  • 19
7

I fixed this problem by adding version:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${project.parent.version}</version>
        </plugin>
    </plugins>
</build>
Arman
  • 111
  • 1
  • 4
4

If solution suggested by Anish B doesn't work and you are using intellij, try deleting the .idea and *.iml file from the project directory and open the pom.xml file with intellij. This should fix the issue.

bluelurker
  • 1,353
  • 3
  • 19
  • 27
4

I faced this error while learning Springboot in 2023, I easily fix it by adding the following line at the spring-boot-starter-web dependency:

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
Alejandro
  • 43
  • 3
3

it works definetely : add this <version>${project.parent.version}</version> in Pom.xml like this :

<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-maven-plugin</artifactId> 
<version>${project.parent.version}</version> 

or another solution is : add <version>2.4.3</version> in pom.xml

Monu Rohilla
  • 1,311
  • 5
  • 20
3

Simply add version of the spring-boot-starter-parent in the plugin section i.e

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>

Change into

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.3.5.RELEASE</version>
</plugin>

check out here for more details

ngTouthang
  • 61
  • 1
  • 10
3

This could be due to network issue which lead to partial download of dependencies and plugins. For me below step worked in IntelliJIDEA:

Close the project from editor: File -> Close Project

Then reopen the project.

Tanu
  • 171
  • 1
  • 6
2

Another possibility is if you have spring-boot-maven-plugin in a sub-module which parent has spring-boot-starter-parent as parent.

So, the module with spring-boot-maven-plugin is a 'grandchild' of spring-boot-starter-parent.

If that's the case, since you can't reference AFAIK the grandparent, you need to manually add its version.

I am open to recommendations, so that I don't need to manually set the version in such a configuration.

gmich
  • 329
  • 2
  • 19
2

I had this issue today 22 Jan 2022 using spring boot 2.6.3 from Intelij IDE and was able to resolve it by changing from 2.6.3 back to 2.6.2 .As of the time of writing I was getting this error

Cannot resolve plugin org.apache.maven.plugins:maven-jar-plugin:3.2.2

    <parent>
      <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>
         <version>2.6.2</version>  <!-- change 2.6.3 to 2.6.2-->
         <relativePath/>
    </parent>
Slycreator
  • 1,144
  • 11
  • 18
1

I tried a lot of the solutions here but only this worked for me:

I changed the Maven wrapper to "Bundled" in the "Maven home path" configuration. You can find this at the menu: Preferences > Build, execution, development > build tools > maven

enter image description here

new Q Open Wid
  • 2,225
  • 2
  • 18
  • 34
Tatiana
  • 11
  • 1
0

Add in "Remote Jar Repositories"

https://mvnrepository.com/artifact/

And add in pom.xml

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>

    </dependency>

then add in *.java

import org.springframework.transaction.annotation.Transactional;
buddemat
  • 4,552
  • 14
  • 29
  • 49
0

I moved my package with controllers into the same package where IntroApplication is, for noobs like me it solved the problem.

0

Right clicking on my pom.xml -> Maven -> Reload Project did the trick for me.

0

just use the last version of spring-boot-maven-plugin

https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-maven-plugin

or use same version of

    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.1</version>
0

For intellij

  • right click on the pom.xml
  • locate maven and select rebuild rebuild project.
Kwesi Welbred
  • 69
  • 1
  • 5
0

In your pom.xml file, go to the plugins section and then add this line below artifactId.

<version>${project.parent.version}</version>

Your code should look like this:

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>

Then load maven changes and it should fix your problem.

Moncef
  • 201
  • 2
  • 5
0

In my case it was just inserting the Spring Boot parent version and the error disappeared spring-boot-starter-parent 3.0.1 stayed like this org.springframework.boot spring-boot-maven-plugin 3.0.1

delios
  • 1
0

For me this was nothing to do with versions or any IDE settings, it was simply calling spring-boot:repackage on its own.

It has to be called with package, so:

mvn package spring-boot:repackage

Has to be done and not:

mvn spring-boot:repackage

I'm assuming that this changes values in the reactor and the second call has a different method to use. When I look at the method that was failing it is now deprecated:

Create a new Packager instance.
Deprecated
since 2.3.10 for removal in 2.5 in favor of Packager(File) and setLayoutFactory(LayoutFactory)
Params:
source – the source archive file to package layoutFactory – the layout factory to use or null

And so probably calling it on its own will result in this method call and thus erroring. The "new" chained method is obviously behaving differently and therefore works.

PeterS
  • 2,818
  • 23
  • 36
-1

Quick solution

I tried all the solutions above and realized that the dependencies were not being downloaded. That's when I knew it was a network issue. My network was strong so I knew it had too be the firewall. I added intellij IDE to my list of exceptions and it worked like charm.

-1

Your dependencies are not loaded into your project if you declared them at a later point.

For IntelliJ IDEA

Right click on your project > Maven > Reload Project

This should fix the error.