【问题标题】:maven jetty - org.mortbay.jetty vs org.eclipse.jettymaven 码头 - org.mortbay.jetty 与 org.eclipse.jetty
【发布时间】:2013-03-13 13:17:39
【问题描述】:

我正在尝试使用码头来托管一个使用 maven 的简单 helloworld servlet。我很困惑。

我关注了这些instructions,但是当我发出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 (/Users/abc/.m2/repository), central (http://repo.maven.apache.org/maven2)]

为了增加混乱,当我在网上搜索示例时,有些是指org.mortbay.jetty,而另一些是指org.eclipse.jetty。我以为 Eclipse 版本是最新的,不是吗?

是否有任何文档描述了maven repo 上托管的每个依赖项的含义?以及如何使用它们?

将版本号修改为9.0.0.v20130308后,我得到一个不同的错误:

Unable to load the mojo 'run' in the plugin 'org.eclipse.jetty:jetty-maven-plugin:9.0.0.v20130308' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/eclipse/jetty/maven/plugin/JettyRunMojo : Unsupported major.minor version 51.0

这是我更新的 pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.neon.research</groupId>
        <artifactId>jetty</artifactId>
        <packaging>war</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>jetty Maven Webapp</name>
        <url>http://maven.apache.org</url>
        <properties>
                <jetty.version></jetty.version>
        </properties>
        <dependencies>
                <dependency>
                        <groupId>org.eclipse.jetty.orbit</groupId>
                        <artifactId>javax.servlet</artifactId>
                        <version>3.0.0.v201112011016</version>
                        <scope>provided</scope>
                </dependency>
        </dependencies>

        <build>
                <plugins>
                        <plugin>
                                <groupId>org.eclipse.jetty</groupId>
                                <artifactId>jetty-maven-plugin</artifactId>
                                <version>9.0.0.v20130308</version>
                        </plugin>
                        <plugin>
                                <artifactId>maven-compiler-plugin</artifactId>
                                <configuration>
                                        <source>1.6</source>
                                        <target>jsr14</target>
                                </configuration>
                                <executions>
                                        <execution>
                                                <id>test-compile</id>
                                                <phase>process-test-sources</phase>
                                                <goals>
                                                        <goal>testCompile</goal>
                                                </goals>
                                                <configuration>
                                                        <source>1.6</source>
                                                        <target>1.6</target>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>
</project>

【问题讨论】:

  • 您是否指定了插件 groupId ?
  • 是的 - 这就是我所拥有的:org.eclipse.jettyjetty-maven-plugin9.0.0
  • 版本不对,请看我更新的答案和评论。
  • 您现在的版本与 Java 不匹配。 Jetty 9 需要 Java 1.7
  • 谢谢andyb。我安装了 1.7,现在它可以工作了。我不知道你怎么知道它是一个 java 版本:-)

标签: maven jetty


【解决方案1】:

码头移动了很多 - 请参阅History。截至 2009 年,Eclipse 是最新的主页。Maven 工件一直在重命名,因此您的搜索正在寻找旧版本 Jetty 和 maven 插件的文档。

最新的 (v9) jetty-maven-plugin documentation 将依赖项列为:

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.0.0.v20130308</version> <!-- latest at time of writing -->
</plugin>

jetty-continuationjetty-jsp 等其他库只是 Jetty 项目的子模块。 Jetty 7 和 8 的 older wiki 上存在一些文档,但我还看不到 v9 的任何更新。模块化设计是 Jetty 开发人员将他们的代码组织成定义明确的模块,这些模块都已单独提供给可能只想使用 Jetty 一小部分的开发人员。

【讨论】:

  • Jetty 9 文档在这里:eclipse.org/jetty/documentation/current
  • @jessemcconnell 谢谢,我已经链接到了。我试图解释没有什么比 v9 的旧 wiki 文档更好的了。例如,Continuations 没有依赖关系图页面,也没有单独的页面。
  • @adnyb 谢谢。我不确定我错过了什么,因为我按照您的描述设置了我的插件。我还指出版本是 9.0.0。
  • @andyb - 感谢您的跟进。我尝试了你的建议,但现在我得到了一个不同的错误。我已经更新了新的错误和 pom 文件。
  • 您现在的版本与 Java 不匹配。 Jetty 9 需要 Java 1.7
【解决方案2】:

eclipse 版本是较新的版本。按照他们网站上的说明进行操作。

【讨论】:

    【解决方案3】:

    这是我的工作配置。 使用最新的 Jetty 版本。

    <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.4.0.v20161208</version>
        <configuration>
            <scanIntervalSeconds>0</scanIntervalSeconds>
            <contextXml>${basedir}/src/it/resources/jetty-context.xml</contextXml>
            <webApp>
                <contextPath>/yourContextPath</contextPath>
            </webApp>
            <contextHandlers>
            <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                <war>your/path.war</war>
                <contextPath>/yourPath</contextPath>
            </contextHandler>
            </contextHandlers>
            <classesDirectory></classesDirectory>
            <webAppSourceDirectory></webAppSourceDirectory>
        </configuration>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 2022-06-17
      • 2013-11-18
      • 2010-11-12
      • 1970-01-01
      • 1970-01-01
      • 2011-01-16
      • 1970-01-01
      • 2010-10-19
      • 1970-01-01
      相关资源
      最近更新 更多