当前项目中没有找到以'jetty'为前缀的插件。

29

我已经在我的项目pom.xml中添加了Jetty Maven插件的代码。

<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
请提出解决办法。谢谢。

尝试在不使用sudo的情况下运行所有mvn命令。 - ivan.sim
可能是缺少Maven插件Jetty的重复问题。 - cellepo
5个回答

42

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

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

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

引用插件开发指南中的缩短命令行部分,

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

<pluginGroups>
  <pluginGroup>sample.plugin</pluginGroup>
</pluginGroups>
请参考这里,了解默认情况下Maven查找groupId的更多信息:

默认情况下,Maven将在org.apache.maven.plugins组中搜索前缀到插件artifactId的映射,以执行给定构建所需的插件。

...

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

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

27

如果您在主目录中找不到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>

2

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

1 打开“运行配置”对话框。

2.查看“基本目录:”,它是否真的是您的Web应用程序子模块的目录,还是父模块的目录?

3 如果是后者,请单击“工作区”按钮,并选择子模块(Web应用程序)的目录。


1
我在项目所在的目录中运行命令,但在切换到包含项目所有文件的上一级目录后,命令正常工作。

0
请注意:

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

mvn spring-boot:run

请确保您在包含pom.xml文件的目录中。否则,您将会遇到当前项目和插件组中没有找到前缀“project-name”的插件错误。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接