26

私はjettyを使用して、mavenを使用して単純なhelloworldサーブレットをホストしようとしています。私はとても混乱しています。

これらの手順に従いましたが、発行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)]

混乱を増すために、Webで例を検索すると、を参照しているものとorg.mortbay.jetty、を参照しているものがありorg.eclipse.jettyます。Eclipseバージョンが最新だと思いましたね。

Mavenリポジトリでホストされている各依存関係の意味を説明するドキュメントはありますか?そして、それらをどのように使用することができますか?

バージョン番号をに変更した後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>
4

3 に答える 3

23

突堤はたくさん動き回っています-歴史を見てください。Eclipseは、2009年現在、最新のホームです。Mavenアーティファクトは途中で名前が変更されたため、検索では、古いバージョンのJettyとMavenプラグインのドキュメントが見つかります。

最新の(v9)jetty-maven-pluginドキュメントには、依存関係が次のようにリストされています。

<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の古いwikiにはいくつかのドキュメントがありますが、v9用に更新されたものはまだ表示されません。モジュラー設計は、Jetty開発者がコードを明確に定義されたモジュールに編成したものであり、Jettyのごく一部を使用したい開発者は、すべて個別に利用できるようになっています。

于 2013-03-13T13:47:13.253 に答える
3

Eclipseバージョンは最新のものです。彼らのサイトの指示に従ってください。

于 2013-03-13T13:46:30.407 に答える
0

これが私のための作業構成です。最新の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>
于 2016-12-21T00:05:48.907 に答える