Java Maven - 在当前项目和插件组中找不到前缀“tomcat7”的插件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24311383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 11:27:12  来源:igfitidea点击:

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

javamaventomcat

提问by agusgambina

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

我已经创建了一个 Maven 项目。这是结构:

-parent
    -core
    -web

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

但是当我尝试使用命令进行部署时mvn tomcat7:deploy,出现以下错误:

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):

我把这个配置放在 pom.xml(web 项目的)中:

<build>
    <finalName>MavenWeb</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>
        </plugin>
    </plugins>
</build>

采纳答案by Tome

Plugins goals can be called using their 'FQN': groupId:artifactId:version:goalor, 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:

可以使用它们的“FQN”调用插件目标:groupId:artifactId:version:goal或者,如果适用,更短的命令(许多变体可用)。仅使用插件的短名称(在您的tomcat7:deploy 中,tomcat7 是短名称,deploy 是目标/mojo)适用于:

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

1)插件的groupId包含在Maven的已知插件组中。org.apache.maven.plugins默认在列表中。

OR

或者

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

您正在调用 Maven 命令的项目的 pom.xml 声明了插件

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

2) artifactId 是[short-name]-maven-pluginmaven-[short-name]-pluginmaven-[short-name]-plugin为 Maven 项目提供的插件“保留”。

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

这就解释了为什么mvn compiler:compile可以在任何项目上开箱即用,而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.xmlfile:

在您的情况下,第二个条件为真,因此您只需在启动命令的项目上声明插件,或将其添加到您的用户settings.xml文件中:

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

See here for more info

在这里查看更多信息

回答by Amir Al

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):

您收到该错误的原因是您还没有安装 Tomcat7 插件。这是你可以做的(我在我的测试项目中测试了它并且它有效):

  1. Add tomcat7 plugin dependency in your pom.xmlfile just like you have done.
  2. Run either mvn installor mvn packageto install that tomcat7 plugin
  3. Now you should be able to run mvn tomcat7:deploy
  1. pom.xml就像您所做的那样,在您的文件中添加 tomcat7 插件依赖项。
  2. 运行mvn installmvn package安装该 tomcat7 插件
  3. 现在你应该可以运行了 mvn tomcat7:deploy

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

我测试了这个解决方案,mvn tomcat7:run它就像一个魅力:)

回答by Sergio Perez

The error happens to have the plugin inside <reporting>, it should be located in <build>

错误恰好在里面有插件<reporting>,它应该位于<build>

Before:

前:

<reporting>
<plugins>
    <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
    <port>8080</port>
    <path>/</path>
    </configuration>
    </plugin>
</plugins>
</reporting>

After:

后:

<build>
<plugins>
    <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
    <port>8080</port>
    <path>/</path>
    </configuration>
    </plugin>
</plugins>
</build>

回答by sapy

It means tomcat7 plugin not found . Add this to your pom.xml.

这意味着找不到 tomcat7 插件。将此添加到您的 pom.xml。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.3-SNAPSHOT</version>
        </plugin>
    </plugins>
</build>

回答by tom

I got the same error from using the file based idp.xml and formatting it!!! Don't format it, use curl, or chrome and save the file from https://idp.ssocircle.com/idp-meta.xmldirectly to spring-security-saml-1.0.2.RELEASE\sample\src\main\resources\metadata\idm.xml

我在使用基于 idp.xml 的文件并对其进行格式化时遇到了同样的错误!!!不要格式化,使用 curl 或 chrome 并将文件从https://idp.ssocircle.com/idp-meta.xml直接保存到 spring-security-saml-1.0.2.RELEASE\sample\src\main \resources\metadata\idm.xml

Then in SecurityContext.cml

然后在 SecurityContext.cml

 <bean id="metadata" class="org.springframework.security.saml.metadata.CachingMetadataManager">
    <constructor-arg>
        <list>
            <!-- Example of classpath metadata with Extended Metadata -->
            <bean class="org.springframework.security.saml.metadata.ExtendedMetadataDelegate">
                <constructor-arg>
                    <bean class="org.opensaml.saml2.metadata.provider.ResourceBackedMetadataProvider">
                        <constructor-arg>
                            <bean class="java.util.Timer"/>
                        </constructor-arg>
                        <constructor-arg>
                            <bean class="org.opensaml.util.resource.ClasspathResource">
                                <constructor-arg value="/metadata/idp.xml"/>
                            </bean>
                        </constructor-arg>
                        <property name="parserPool" ref="parserPool"/>
                    </bean>
                </constructor-arg>
                <constructor-arg>
                    <bean class="org.springframework.security.saml.metadata.ExtendedMetadata">
                    </bean>
                </constructor-arg>
            </bean>

</bean>

回答by H.Mims

After I checked my pom.xml file, I made sure all my dependencies were selected in the build order under the JAVA Build Path JAVA BUILD PATH

检查我的 pom.xml 文件后,我确保在 JAVA Build Path JAVA BUILD PATH下的构建顺序中选择了所有依赖项