在Java 11中使用jetty-maven-plugin时遇到问题,我尝试在插件依赖项中明确指定与Java 11兼容的asm版本。
我的配置:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.12.v20180830</version>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>6.2.1</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2.1</version>
</dependency>
</dependencies>
<configuration>
<httpConnector>
<port>9090</port>
</httpConnector>
<stopPort>8005</stopPort>
<stopKey>STOP</stopKey>
<webApp>
<contextPath>/</contextPath>
</webApp>
<jvmArgs>-Dfile.encoding=UTF-8</jvmArgs>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
此操作失败
....
Caused by: java.lang.UnsupportedOperationException
at org.objectweb.asm.ClassVisitor.visitNestHostExperimental (ClassVisitor.java:158)
at org.objectweb.asm.ClassReader.accept (ClassReader.java:541)
at org.objectweb.asm.ClassReader.accept (ClassReader.java:391)
at org.eclipse.jetty.annotations.AnnotationParser.scanClass (AnnotationParser.java:933)
at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry (AnnotationParser.java:917)
at org.eclipse.jetty.annotations.AnnotationParser.lambda$parseJar$0 (AnnotationParser.java:876)
at java.util.TreeMap$ValueSpliterator.forEachRemaining (TreeMap.java:2890)
at java.util.stream.ReferencePipeline$Head.forEach (ReferencePipeline.java:658)
at org.eclipse.jetty.annotations.AnnotationParser.parseJar (AnnotationParser.java:872)
at org.eclipse.jetty.annotations.AnnotationParser.parse (AnnotationParser.java:836)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call (AnnotationConfiguration.java:163)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run (AnnotationConfiguration.java:471)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run (QueuedThreadPool.java:683)
at java.lang.Thread.run (Thread.java:834)
尝试使用其他asm版本(例如6.1.1)失败,并显示以下信息:
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 55
at org.objectweb.asm.ClassReader.<init> (ClassReader.java:166)
at org.objectweb.asm.ClassReader.<init> (ClassReader.java:148)
at org.objectweb.asm.ClassReader.<init> (ClassReader.java:136)
at org.objectweb.asm.ClassReader.<init> (ClassReader.java:237)
at org.eclipse.jetty.annotations.AnnotationParser.scanClass (AnnotationParser.java:932)
at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry (AnnotationParser.java:917)
at org.eclipse.jetty.annotations.AnnotationParser.lambda$parseJar$0 (AnnotationParser.java:876)
at java.util.TreeMap$ValueSpliterator.forEachRemaining (TreeMap.java:2890)
at java.util.stream.ReferencePipeline$Head.forEach (ReferencePipeline.java:658)
at org.eclipse.jetty.annotations.AnnotationParser.parseJar (AnnotationParser.java:872)
at org.eclipse.jetty.annotations.AnnotationParser.parse (AnnotationParser.java:836)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call (AnnotationConfiguration.java:163)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run (AnnotationConfiguration.java:471)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run (QueuedThreadPool.java:683)
at java.lang.Thread.run (Thread.java:834)
有什么方法可以使Jetty Maven插件与Java 11一起运行?
答案 0 :(得分:0)
使用jetty-maven-plugin,一切似乎都能按预期工作»9.4.14.v20181114
答案 1 :(得分:-1)
...
<packaging>war</packaging>
<name>test-project</name>
<properties>
<maven.compiler.source>JavaVersion</maven.compiler.source>
<maven.compiler.target>javaVersion</maven.compiler.target>
</properties>
....
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>