所以我尝试用jsp构建一个spring应用,用jetty运行,它给了我一个警告,然后失败了,因为它试图运行多个WebApplicationInitializers。我已经尝试了我所看到的一切,我找不到问题。
在检测到2个WebApplicationInitializers之前有很多警告:
[INFO] jetty-9.4.43.v20210629; built: 2021-06-30T11:07:22.254Z; git: 526006ecfa3af7f1a27ef3a288e2bef7ea9dd7e8; jvm 18.0.2.1+1-1
[WARNING] org.apache.taglibs.standard.Version scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/Version.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/Version.class
[WARNING] org.apache.taglibs.standard.functions.Functions scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/functions/Functions.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/functions/Functions.class
[WARNING] org.apache.taglibs.standard.resources.Resources scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/resources/Resources.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/resources/Resources.class
[WARNING] org.apache.taglibs.standard.tag.common.core.CatchTag scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/CatchTag.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/CatchTag.class
[WARNING] org.apache.taglibs.standard.tag.common.core.ChooseTag scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/ChooseTag.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/ChooseTag.class
[WARNING] org.apache.taglibs.standard.tag.common.core.DeclareTag scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/DeclareTag.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/DeclareTag.class
[WARNING] org.apache.taglibs.standard.tag.common.core.ForEachSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/ForEachSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/ForEachSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.core.ForTokensSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/ForTokensSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/ForTokensSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.core.ImportSupport$ImportResponseWrapper$1 scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/ImportSupport$ImportResponseWrapper$1.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/ImportSupport$ImportResponseWrapper$1.class
[WARNING] org.apache.taglibs.standard.tag.common.core.ImportSupport$ImportResponseWrapper scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/ImportSupport$ImportResponseWrapper.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/ImportSupport$ImportResponseWrapper.class
[WARNING] org.apache.taglibs.standard.tag.common.core.ImportSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/ImportSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/ImportSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.core.NullAttributeException scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/NullAttributeException.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/NullAttributeException.class
[WARNING] org.apache.taglibs.standard.tag.common.core.OtherwiseTag scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/OtherwiseTag.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/OtherwiseTag.class
[WARNING] org.apache.taglibs.standard.tag.common.core.OutSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/OutSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/OutSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.core.ParamParent scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/ParamParent.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/ParamParent.class
[WARNING] org.apache.taglibs.standard.tag.common.core.ParamSupport$ParamManager scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/ParamSupport$ParamManager.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/ParamSupport$ParamManager.class
[WARNING] org.apache.taglibs.standard.tag.common.core.ParamSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/ParamSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/ParamSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.core.RedirectSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/RedirectSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/RedirectSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.core.RemoveTag scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/RemoveTag.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/RemoveTag.class
[WARNING] org.apache.taglibs.standard.tag.common.core.SetSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/SetSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/SetSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.core.UrlSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/UrlSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/UrlSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.core.Util scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/Util.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/Util.class
[WARNING] org.apache.taglibs.standard.tag.common.core.WhenTagSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/core/WhenTagSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/core/WhenTagSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.fmt.BundleSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.fmt.FormatDateSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/fmt/FormatDateSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/fmt/FormatDateSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.fmt.FormatNumberSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/fmt/FormatNumberSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/fmt/FormatNumberSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.fmt.MessageSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/fmt/MessageSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/fmt/MessageSupport.class
[WARNING] org.apache.taglibs.standard.tag.common.fmt.ParamSupport scanned from multiple locations: jar:file:///root/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar!/org/apache/taglibs/standard/tag/common/fmt/ParamSupport.class, jar:file:///root/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar!/org/apache/taglibs/standard/tag/common/fmt/ParamSupport.class
(还有更多,但我不能全部发布)
最后的警告和错误是:
[INFO] Scanning elapsed time=143ms
[INFO] 2 Spring WebApplicationInitializers detected on classpath
[WARNING] Failed startup of context o.e.j.m.p.JettyWebAppContext@daf22f0{/,file:///mnt/target/webapp-tmp/,UNAVAILABLE}{file:///mnt/target/webapp-tmp/}
java.lang.AbstractMethodError: Receiver class org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration$JerseyWebApplicationInitializer does not define or inherit an implementation of the resolved method 'abstract void onStartup(javax.servlet.ServletContext)' of interface org.springframework.web.WebApplicationInitializer.
at org.springframework.web.SpringServletContainerInitializer.onStartup (SpringServletContainerInitializer.java:169)
at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup (ContainerInitializer.java:142)
at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart (ServletContainerInitializersStarter.java:64)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:73)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:356)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp (WebAppContext.java:1449)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp (JettyWebAppContext.java:328)
at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1414)
at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:910)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart (ServletContextHandler.java:288)
at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:524)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:397)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:73)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:97)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:73)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:97)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:73)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:169)
at org.eclipse.jetty.server.Server.start (Server.java:423)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:110)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:97)
at org.eclipse.jetty.server.Server.doStart (Server.java:387)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:73)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty (AbstractJettyMojo.java:449)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute (AbstractJettyMojo.java:310)
at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:150)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:577)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.675 s
[INFO] Finished at: 2023-03-17T12:46:57Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.4.43.v20210629:run (default-cli) on project demo2: Failure: Failed to bind to 0.0.0.0/0.0.0.0:8080: Address already in use -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
我的pom.xml:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.4</version>
</parent>
<groupId>com.hatoku</groupId>
<artifactId>demo2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.43.v20210629</version>
<configuration>
<scanIntervalSeconds>3</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
</project>
我试着主要删除可能是一个问题的依赖项,但它仍然给我同样的问题无论如何。
1条答案
按热度按时间q9yhzks01#
看起来JDK(17)和spring Boot (3.0.4)的版本与pom.xml中spring(4.3.9.RELEAS)和jetty(9.4.43.v20210629)的版本不兼容。
您可以将spring版本调整为
5.3.26
,将jetty版本调整为11.0.14
,并尝试一下。我不确定它是否工作,基本上你需要使jetty,spring,jdk版本兼容。