Search code examples
javamavenintellij-idea

How to fix error not found plugin maven-surefire-plugin >= 2.20 on IntelliJ


I tried to migrate to java 11. But when I change the version of plugin maven-surefire-plugin to 2.22.2 that supports java 11, maven or IntelliJ can not find it:

enter image description here

I tried with other versions >= 2.20, but had same error. I tried to fix it:

  1. Firstly, invalidate caches and restart IntelliJ, then reimport maven. But still error.
  2. I deleted all directories in ~/.m2/repository/org/apache/maven/plugins, and then reimport maven. But maven imported plugin maven-surefire-plugin version 2.19.1 automatically, not imported version 2.22.2 (:

enter image description here

  • Update: I installed maven-surefire-plugin version 2.22.2 successfully by maven command line: mvn install. It downloaded the plugin but IntelliJ still has the error. I tried to invalidate caches and restart IntelliJ, it worked.

Thanks @Andrey for the great suggestion!


Solution

  • I fixed this issue, I do:

    • I installed maven-surefire-plugin version 2.22.2 successfully by maven command line: mvn install. It downloaded the plugin but IntelliJ still has the error.
    • And then I tried to invalidate caches and restart IntelliJ, it worked.

    Thanks @Andrey for the great suggestion!