Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven - No plugin found for prefix 'tomcat7' in the current project and in the plugin groups

Tags:

java

maven

tomcat

I've created a Maven project. This is the structure:

-parent     -core     -web 

but when I try to deploy with the command mvn tomcat7:deploy, I get the following error:

No plugin found for prefix 'tomcat7' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] 

I put this configuration in the pom.xml (of the web project):

<build>     <finalName>MavenWeb</finalName>     <plugins>         <plugin>             <groupId>org.apache.tomcat.maven</groupId>             <artifactId>tomcat7-maven-plugin</artifactId>             <version>2.0</version>         </plugin>     </plugins> </build> 
like image 740
agusgambina Avatar asked Jun 19 '14 16:06

agusgambina


2 Answers

Plugins goals can be called using their 'FQN': groupId:artifactId:version:goal or, if applicable, shorter commands (many variants available). Using only the short name of a plugin (in your tomcat7:deploy, tomcat7 is the short name, deploy being the goal/mojo) is applicable if:

1) the groupId of the plugin is contained in the known plugin groups of Maven. org.apache.maven.plugins being in the list by default.

OR

the pom.xml of the project you're invoking the Maven command on declares the plugin

2) the artifactId is [short-name]-maven-plugin or maven-[short-name]-plugin (maven-[short-name]-plugin being 'reserved' for plugins provided by Maven project.

That explains why mvn compiler:compile can work out of the box on any project, but not tomcat7:deploy

In your case, the second condition is true, so you just have to declare the plugin on the project you're launching the command on, or add this to your user settings.xml file:

<pluginGroups>   <pluginGroup>org.apache.tomcat.maven</pluginGroup> </pluginGroups> 

See here for more info

like image 150
Tome Avatar answered Sep 17 '22 20:09

Tome


The reason why you get that error is because you simply have not installed the Tomcat7 plugin. Here's what you can do (I tested this on my test project and it works):

  1. Add tomcat7 plugin dependency in your pom.xml file just like you have done.
  2. Run either mvn installor mvn package to install that tomcat7 plugin
  3. Now you should be able to run mvn tomcat7:deploy

I tested this solution with mvn tomcat7:run and it works like a charm :)

like image 27
Amir Al Avatar answered Sep 19 '22 20:09

Amir Al