【问题标题】:No plugin found for prefix 'jetty' in the current project在当前项目中找不到前缀“jetty”的插件
【发布时间】:2015-02-28 12:49:50
【问题描述】:

我在我的项目 pom.xml 中添加了 jetty mvn 插件代码。

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty-plugin</artifactId>
  <version>6.1.26</version>
  <configuration>
    <contextPath>/redkites</contextPath>
  </configuration>
  <executions>
    <execution>
      <id>start-jetty</id>
      <phase>deploy</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <scanIntervalSeconds>10</scanIntervalSeconds>
        <daemon>true</daemon>
      </configuration>
    </execution>
  </executions>
</plugin>

当我使用命令sudo mvn compilesudo mvn clean install 时,我没有发现任何错误并成功构建,但是当我输入命令sudo mvn jetty:run 时,我得到一个错误:

[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 (/root/.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.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

请提出解决方法。谢谢

【问题讨论】:

标签: maven jetty maven-jetty-plugin


【解决方案1】:

请注意:

如果您使用以下命令运行您的应用程序:

mvn spring-boot:run

确保您位于包含 pom.xml 文件的目录中。否则,您将在当前项目和插件组中遇到 No plugin found for prefix 'project-name' 错误。

【讨论】:

    【解决方案2】:

    您可能需要将org.eclipse.jetty 添加到默认查找的groupIds 列表中。

    因此请相应地编辑您的${user.home}/.m2/settings.xml

    <pluginGroups>
      <!-- your existing plugin groups if any -->
      ...
      <pluginGroup>org.eclipse.jetty</pluginGroup>
    </pluginGroups>
    

    引用plugin development guideShortening the Command Line 部分,

    ... 将插件的 groupId 添加到搜索的 groupId 列表中 默认。为此,您需要将以下内容添加到您的 ${user.home}/.m2/settings.xml 文件:

    <pluginGroups>
      <pluginGroup>sample.plugin</pluginGroup>
    </pluginGroups>
    

    查看here 了解更多关于groupIds 被默认查找的内容:

    默认情况下,Maven 将在 groupId org.apache.maven.plugins 中搜索 它需要执行的插件的前缀到工件 ID 映射 给定的构建。

    ...

    Maven 将始终搜索以下 groupId 搜索用户设置中指定的任何插件组后:

    • org.apache.maven.plugins
    • org.codehaus.mojo

    【讨论】:

      【解决方案3】:

      如果您在主目录中没有找到 settings.xml 文件

      然后添加默认的settings.xml文件

      <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                            http://maven.apache.org/xsd/settings-1.0.0.xsd">
        <localRepository>${user.home}/.m2/repository</localRepository>
        <interactiveMode>true</interactiveMode>
        <usePluginRegistry>false</usePluginRegistry>
        <offline>false</offline>
        <pluginGroups>
          <pluginGroup>org.eclipse.jetty</pluginGroup>
        </pluginGroups>
      </settings>
      

      【讨论】:

        【解决方案4】:

        我在项目所在的目录中运行该命令,但在切换到上一个目录后该命令运行良好,即在其中一个项目的所有文件都存在。

        【讨论】:

          【解决方案5】:

          这就是在 Eclipse 中的多模块 Maven 项目中对我有用的方法:

          1 打开运行配置对话框。

          2.查看“基本目录”:真的有你的webapp的子模块的目录还是父模块的目录?

          3 如果是后者,点击“Workspace”按钮,选择子模块(webapp的)目录。

          【讨论】:

            猜你喜欢
            • 2016-07-09
            • 2014-01-31
            • 2021-05-31
            • 2020-06-24
            • 2018-04-28
            • 1970-01-01
            • 1970-01-01
            • 2014-08-10
            • 2019-08-09
            相关资源
            最近更新 更多