简体   繁体   English

Maven-在当前项目中未找到前缀“ tomcat7”的插件

[英]Maven - No plugin found for prefix 'tomcat7' in the current project

I've created a Maven project with the archetype "webapp" but when I start the command "mvn tomcat7:start", I've the following error : 我已经创建了一个原型为“ 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.

My project structure : 我的项目结构:

-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

My pom.xml contains well the dependency for tomcat. 我的pom.xml很好地包含了tomcat的依赖关系。

pom.xml pom.xml

<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 http://maven.apache.org/maven-v4_0_0.xsd">

 <modelVersion>4.0.0</modelVersion>
 <groupId>com.myspace</groupId>
 <artifactId>lbagno</artifactId>
 <packaging>war</packaging>
 <version>0.0.1-SNAPSHOT</version>
 <name>lbagno Maven Webapp</name>
 <url>http://maven.apache.org</url>


 <dependencies>
     <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>3.8.1</version>
         <scope>test</scope>
     </dependency>

     <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-core</artifactId>
         <version>3.1.0.RELEASE</version>
     </dependency>

     <dependency>
         <groupId>org.apache.tomcat.maven</groupId>
         <artifactId>tomcat7-maven-plugin</artifactId>
         <version>2.2</version>
         <type>maven-plugin</type>
     </dependency>
 </dependencies>

 <build>
    <finalName>lbagno</finalName>
 </build>

</project>

I don't understand why it doesn't work. 我不明白为什么它不起作用。

Do you have any solutions ? 你有什么解决方案 ?

Thank you 谢谢

I know it was asked a year ago, but my answer might work for somebody other than me. 我知道是一年前提出的,但是我的回答可能对我以外的其他人有用。

If creating the build tag in the pom.xml file not works, try editing the settings.xml file at your .m2 directory this way: 如果无法在pom.xml文件中创建构建标记,请尝试通过以下方式在.m2目录中编辑settings.xml文件:

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

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

First, there is no start goal, see the goals page of the doc. 首先,没有开始目标,请参阅文档的目标页面

Next, it's a plugin, you declared it as a dependency, this is why you get this error, I suggest you read the usage page of the plugin. 接下来,它是一个插件,您将其声明为依赖项,这就是为什么出现此错误的原因,建议您阅读插件的用法页面

Here is a schematic structure of the pom.xml : 这是pom.xml的示意图结构:

<project>
    <!-- ... -->

    <dependencies>
        <!-- your deps here -->
    </dependencies>

    <build>
        <plugins>
            <!-- your default build plugins here -->
        </plugins>
    <build>

    <!-- ... -->
</project>

这为我工作:

mvn clean install tomcat7:run

Run mvn with -X -e params. 使用-X -e参数运行mvn。 This should give you more information about the error. 这应该为您提供有关该错误的更多信息。

I saw that you don't have any pluginRepositories declared. 我看到您没有声明任何pluginRepositories Add the following lines to your pom.xml: 将以下行添加到pom.xml中:

<pluginRepositories>
    <pluginRepository>
        <id>apache.snapshots</id>
        <name>Apache Snapshots</name>
        <url>http://repository.apache.org/content/groups/snapshots-group/</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

Try to delete this part from your dependency and put this line of code in plugins on your projects pom.xml. 尝试从依赖项中删除此部分,并将此行代码放入项目pom.xml的插件中。 From dependency delete this line of codes: 从依赖项中删除以下代码行:

  <dependency>
     <groupId>org.apache.tomcat.maven</groupId>
     <artifactId>tomcat7-maven-plugin</artifactId>
     <version>2.2</version>
     <type>maven-plugin</type>
 </dependency>

and put this in .... 并把它放在....

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
</plugin>

This will surely work. 这肯定会起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Maven - 在当前项目和插件组中找不到前缀'tomcat7'的插件 - Maven - No plugin found for prefix 'tomcat7' in the current project and in the plugin groups Maven - 在当前项目中找不到前缀&#39;wildfly&#39;的插件 - Maven - No plugin found for prefix 'wildfly' in the current project Maven-在当前项目中未找到前缀&#39;spring-boot&#39;的插件 - Maven- No plugin found for prefix 'spring-boot' in the current project Tomcat7 Maven插件和JaCoCo - Tomcat7 Maven Plugin and JaCoCo 错误“在当前项目和插件组中找不到前缀‘原型’的插件”在创建新的 java maven 项目中 - Error "No plugin found for prefix 'archetype' in the current project and in the plugin groups" getting in creating new java maven project Maven PITest 错误“在当前项目和插件组中找不到前缀 'org.pitest' 的插件” - Maven PITest Error “No plugin found for for prefix 'org.pitest' in the current project and in the plugin groups” JavaFX Maven插件:在当前项目和插件组中找不到前缀“ jfx”的插件 - JavaFX Maven Plug-in: No plugin found for prefix 'jfx' in the current project and in the plugin groups Maven 抛出错误:在当前项目和插件组中找不到前缀“程序集”的插件 - Maven throws error: No plugin found for prefix 'assembly' in the current project and in the plugin groups Maven-在当前项目和插件组中找不到前缀“spring-boot”的插件 - Maven- No plugin found for prefix 'spring-boot' in the current project and in the plugin groups 在当前项目中找不到前缀“dependancy”的插件 - No plugin found for prefix 'dependancy' in the current project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM