在当前项目和插件组(本地,中央)中找不到前缀'jetty'的插件

Nic*_*oul 10 maven maven-jetty-plugin

为了轻松运行我的webapp,我决定将Jetty添加到我的单个POM文件中.

官方文档之后,我将此添加到我的<plugins>:

  <plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.4.0-SNAPSHOT</version>
  </plugin>
Run Code Online (Sandbox Code Playgroud)

问题:mvn jetty:run失败:

$ mvn jetty:start
[INFO] Scanning for projects...
[WARNING] The POM for org.eclipse.jetty:jetty-maven-plugin:jar:9.4.0-SNAPSHOT is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.eclipse.jetty:jetty-maven-plugin:9.4.0-SNAPSHOT: Plugin org.eclipse.jetty:jetty-maven-plugin:9.4.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.eclipse.jetty:jetty-maven-plugin:jar:9.4.0-SNAPSHOT
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 2.1 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 3.2 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.013 s
[INFO] Finished at: 2016-08-17T16:49:28+09:00
[INFO] Final Memory: 14M/307M
[INFO] ------------------------------------------------------------------------
[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 (/home/nico/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-maven-plugin/9.4.0.M0中的另一种方法建议将其添加到<dependencies>:

            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.4.0.M0</version>
            </dependency>
Run Code Online (Sandbox Code Playgroud)

它也失败了,mvn jetty:start说:

[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 (/home/nico/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

我删除了我的.m2文件夹,让Maven重新创建它,没有更好的.我没有settings.xml,~/.m2这里的内容是~/.m2/repository/org/eclipse/jetty/jetty-maven-plugin/9.4.0.M0/:

-rw-rw-r-- 1 nico nico 101524  8? 24 17:29 jetty-maven-plugin-9.4.0.M0.jar
-rw-rw-r-- 1 nico nico     40  8? 24 17:29 jetty-maven-plugin-9.4.0.M0.jar.sha1
-rw-rw-r-- 1 nico nico   5526  8? 24 17:28 jetty-maven-plugin-9.4.0.M0.pom
-rw-rw-r-- 1 nico nico     40  8? 24 17:28 jetty-maven-plugin-9.4.0.M0.pom.sha1
-rw-rw-r-- 1 nico nico    215  8? 24 17:29 _remote.repositories
Run Code Online (Sandbox Code Playgroud)

注意:关于同一主题有几个问题,所有问题都有过时的答案,其中包含Maven ids(mortbay,codehaus),这些答案可以追溯到Jetty迁移到Eclipse之前,或者建议添加在<plugin>我的问题顶部看到的块.

Jos*_*rdt 15

您正在使用插件版本9.4.0-SNAPSHOT.此版本在中央仓库(可用版本)中不可用.

添加a dependency不能解决问题,因为依赖项与a不同plugin.您要编译的代码使用或需要依赖项,插件可以编译,构建或分析您的代码.

简而言之:

  • 你不需要dependency打开jetty-maven-plugin
  • 你必须改变versionplugin一个版本,这是在中央或当地回购可用.
    例如:

    <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.4.0.M0</version>
    </plugin>
    
    Run Code Online (Sandbox Code Playgroud)


小智 5

请使用以下信息编辑本地存储库中的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.mortbay.jetty</pluginGroup>
  </pluginGroups>
</settings>
Run Code Online (Sandbox Code Playgroud)

它对我有用。