“Plugin not found for prefix” error in Eclipse

2019-01-24 02:38发布

问题:

In Eclipse I imported a maven-based project which uses maven jetty plugin. If I run mvn jetty:run from command line, everything works fine. If I add a run configuration in Eclipse and try to run it, I get the error message:

[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/eugene/.m2/repository), central (http://repo1.maven.org/maven2)] -> [Help 1]

In the Eclipe run configuration, I use:

  • Base directory: ${project_loc}
  • Goal: jetty:run
  • Maven Runtime: External

I read the [Help1] page. I don't have pluginGroup settings in maven configuration files, but I have the jetty plugin mentioned in pom.xml, so I guess everything should be fine (especially because everything works in command-line). I tried to "Run as > Maven clean" in Eclipse before executing the jetty run configuration, but it didn't help. Project compiles and passes all tests, only jetty:run does not work in Eclipse.

Please help, I'm an Eclipse & Maven newbie. Thanks in advance.

回答1:

It does not work for me from command-line either.

Can you check if it works after adding the following in settings.xml as documented?

<pluginGroups>
    <pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>

Also note that there are two different versions of the plugin - the older maven jetty plugin and the newer jetty maven plugin.



回答2:

I met this problem too, an easier way to solve this is to edit your pom.xml, add following plugin:

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>7.6.8.v20121106</version>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

Note:

  1. jetty-maven-plugin is used for jetty version 7 and above, if you want jetty version 6, you should use maven-jetty-plugin

  2. for the version, you may want to have a look at here and here for your desired version's full name.



回答3:

I apologize for wasting your time. Now I looked through maven warnings which appeared in Eclipse console after I ran the run configuration. I noticed

[WARNING] Failed to retrieve plugin descriptor for Plugin [org.mortbay.jetty:maven-jetty-plugin]: null

so it became obvious why it couldn't recognize jetty: prefix. Couple of lines above I saw a bunch of warnings about missing plugin versions. So I added a version specification for the jetty plugin (<version> entry in pom.xml) and it solved the problem. I forgot a common rule that if something breaks the first thing to check is warnings you get.



回答4:

I've got this issue in eclipse after importing an appengine project.

The target:

mvn appengine:devserver

The error:

[ERROR] No plugin found for prefix 'appengine' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/averasko/.m2/repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]

The problem was in the incorrect base directory in the eclipse run configuration. When maven does not see a pom.xml file and is asked to run some non-standard target if fails like this as it don't know anything about the plugin that defines the target.

The solution is to correct the base directory to wherever your pom.xml file resides.



回答5:

if you following this tutorial:

http://tapestry.apache.org/creating-the-skeleton-application.html

don't forget to follow this one crucial instruction:

Change into the newly created directory, and execute the command: