在当前项目中找不到前缀'jetty'的插件

Pra*_*ash 27 jetty maven maven-jetty-plugin

我在项目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>
Run Code Online (Sandbox Code Playgroud)

当我使用命令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
Run Code Online (Sandbox Code Playgroud)

请提出解决方法.谢谢

mys*_*cks 39

您可能需要添加org.eclipse.jettygroupId默认情况下查找的列表中.

所以编辑你的${user.home}/.m2/settings.xml相应:

<pluginGroups>
  <!-- your existing plugin groups if any -->
  ...
  <pluginGroup>org.eclipse.jetty</pluginGroup>
</pluginGroups>
Run Code Online (Sandbox Code Playgroud)

引用插件开发指南Shortening the Command Line部分,

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

<pluginGroups>
  <pluginGroup>sample.plugin</pluginGroup>
</pluginGroups>
Run Code Online (Sandbox Code Playgroud)

在这里查看更多关于groupId默认查找的内容:

默认情况下,Maven将搜索groupId org.apache.maven.plugins,以获取执行给定构建所需的插件的prefix-to-artifactId映射.

...

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

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


小智 26

如果在主目录中找不到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>
Run Code Online (Sandbox Code Playgroud)