Maven – 在当前项目中找不到前缀’tomcat7’的插件

我用原型“webapp”创建了一个Maven项目但是当我启动命令“mvn tomcat7:start”时,我遇到以下错误:

No plugin found for prefix 'tomcat7' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\dark\.m2\repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. 

我的项目结构:

 -src -main -resources -webapp -WEB-INF -web.xml -index.jsp -target -classes -dependency - // the 'dependency' directory contains all the jar files -lbagno -maven-archiver -surefire lbagno.war 

我的pom.xml包含了tomcat的依赖项。

的pom.xml

  4.0.0 com.myspace lbagno war 0.0.1-SNAPSHOT lbagno Maven Webapp http://maven.apache.org   junit junit 3.8.1 test   org.springframework spring-core 3.1.0.RELEASE   org.apache.tomcat.maven tomcat7-maven-plugin 2.2 maven-plugin    lbagno   

我不明白为什么它不起作用。

你有什么解决办法 ?

谢谢

我知道一年前有人问过,但我的回答可能对我以外的人有用。

如果在pom.xml文件中创建构建标记不起作用,请尝试以这种方式编辑.m2目录中的settings.xml文件:

  ... org.apache.tomcat.maven ...  

我在这里找到了解决方案: http : //tomcat.apache.org/maven-plugin-2.2/

首先,没有开始目标,请参阅文档的目标页面 。

接下来,它是一个插件,你声明它是一个依赖项,这就是你得到这个错误的原因,我建议你阅读插件的使用页面 。

这是pom.xml的原理图结构:

             

这对我有用:

 mvn clean install tomcat7:run 

使用-X -e params运行mvn。 这应该为您提供有关错误的更多信息。

我看到你没有声明任何pluginRepositories 。 将以下行添加到您的pom.xml:

   apache.snapshots Apache Snapshots http://repository.apache.org/content/groups/snapshots-group/  false   true    

尝试从依赖项中删除此部分,并将这行代码放在项目pom.xml上的插件中。 从依赖项删除此行代码:

   org.apache.tomcat.maven tomcat7-maven-plugin 2.2 maven-plugin  

把它放进……

  org.apache.tomcat.maven tomcat7-maven-plugin 2.2  

这肯定会奏效。