我一直在将 Spring Boot 应用程序升级到 Spring Boot 3 (3.3.1),所以我需要将 jetty 版本升级到 12,所以我这么做了。但是当我尝试升级 jetty-maven-plugin 时,它也会在启动时失败。 这是错误:
[WARNING] Failed startup of context oeje10mp.MavenWebAppContext@19105a87{/artifactId,/artifactId,b=file:///C:/Users/username/git/projectname/web-app/src/main/webapp/,a=STOPPED,h=oeje10s.SessionHandler@83b0d0f{STOPPED}}{./webapps/project-version-project.war}
java.lang.IllegalArgumentException: File not resolvable or incompatible with URLClassloader: file:///C:/Users/username/git/projectname/web-app/./resources/projectArtifactId
at org.eclipse.jetty.ee10.webapp.WebAppClassLoader.addClassPath (WebAppClassLoader.java:260)
at org.eclipse.jetty.ee10.webapp.WebAppClassLoader.<init> (WebAppClassLoader.java:212)
at org.eclipse.jetty.ee10.webapp.WebAppContext.configureClassLoader (WebAppContext.java:469)
at org.eclipse.jetty.ee10.webapp.WebAppContext.preConfigure (WebAppContext.java:442)
at org.eclipse.jetty.ee10.webapp.WebAppContext.doStart (WebAppContext.java:498)
at org.eclipse.jetty.ee10.maven.plugin.MavenWebAppContext.doStart (MavenWebAppContext.java:311)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:120)
at org.eclipse.jetty.server.Handler$Abstract.doStart (Handler.java:491)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
at org.eclipse.jetty.server.Server.start (Server.java:624)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:120)
at org.eclipse.jetty.server.Handler$Abstract.doStart (Handler.java:491)
at org.eclipse.jetty.server.Server.doStart (Server.java:565)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
at org.eclipse.jetty.maven.AbstractJettyEmbedder.doStart (AbstractJettyEmbedder.java:206)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
at org.eclipse.jetty.ee10.maven.plugin.JettyRunMojo.startJettyEmbedded (JettyRunMojo.java:98)
at org.eclipse.jetty.ee10.maven.plugin.AbstractWebAppMojo.startJetty (AbstractWebAppMojo.java:451)
at org.eclipse.jetty.ee10.maven.plugin.AbstractWebAppMojo.execute (AbstractWebAppMojo.java:429)
at org.eclipse.jetty.ee10.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:86)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
这是更新后的 pom.xml(部分):
<plugin>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-maven-plugin</artifactId>
<version>12.0.10</version>
<configuration>
<testClassesDirectory>${project.basedir}/target/resources</testClassesDirectory>
<!-- <useTestClasspath>true</useTestClasspath>-->
<!-- <webAppXml>${project.build.outputDirectory}/jetty-web.xml</webAppXml>-->
<useTestScope>true</useTestScope>
<contextXml>${project.build.outputDirectory}/jetty-web.xml</contextXml>
<httpConnector>
<port>15600</port>
</httpConnector>
</configuration>
</plugin>
这是 jetty-web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.ee10.webapp.WebAppContext">
<Set name="contextPath">/${deployable.artifactId}</Set>
<Set name="war">
<SystemProperty name="config.home" default="."/>/webapps/${deployable.artifactId}-${project.version}.war
</Set>
<!--Allow log4j & other properties to be loaded outside of the WAR depending on environment-->
<Set name="extraClasspath">
<SystemProperty name="config.home" default="."/>/resources/${deployable.artifactId}
</Set>
</Configure>
如果使用
org.eclipse.jetty:jetty-maven-plugin
版本 11.0.14 或使用更新的插件但从 xml 文件中删除设置的 extraClasspath 属性,它会如何工作。版本 12 中的 extraClasspath 属性或其用法是否发生了变化?我还没找到任何东西。
正如 @Joakim Erdfelt 在评论中指出的那样,新版本无法将 extraClasspath 设置为不存在的路径,这与旧版本相反。