无法启动'webServerStartStop' Spring 启动应用程序



在尝试运行我的应用程序后,此处存在哪个主类:

@SpringBootApplication public class RappersInfo {
public static void main(String[] args) {
SpringApplication.run(RappersInfo.class, args);
}   @Component
public class JspContextCustomizer implements TomcatContextCustomizer {
@Override
public void customize(Context context) {
JspPropertyGroup group = new JspPropertyGroup();
group.addUrlPattern("/*");
group.setPageEncoding("UTF-8");
context.setJspConfigDescriptor(new JspConfigDescriptorImpl(
Collections.singletonList(new JspPropertyGroupDescriptorImpl(group)),
Collections.emptyList()));
}
}
}

我在尝试运行类后出现了错误

org.springframework.context.ApplicationContextException:无法启动bean"webServerStartStop";嵌套异常为org.springframework.boot.web.server.WebServer异常:无法启动嵌入式Tomcat服务器位于org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecyclePprocessor.java:181)~[spring-context-5.3.24.jar:5.3.24]位于org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecyclePprocessor.java:54)~[spring-context-5.3.24.jar:5.3.24]位于org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecyclePprocessor.java:356)~[spring-context-5.3.24.jar:5.3.24]在java.base/java.lang.Iterable.forEach(Iterable.java:75)~[na:na]位于org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecyclePprocessor.java:155)~[spring-context-5.3.24.jar:5.3.24]位于org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecyclePprocessor.java:123)~[spring-context-5.3.24.jar:5.3.24]网址:org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)~[spring-context-5.3.24.jar:5.3.24]网址:org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)~[spring-context-5.3.24.jar:5.3.24]网址:org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplication context.java:147)~[spring-boot-2.7.6.jar:2.7.6]网址:org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)~[spring-boot-2.7.6.jar:2.7.6]网址:org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)~[spring-boot-2.7.6.jar:2.7.6]网址:org.springframework.boot.SpringApplication.run(SpringApplication.java:307)~[spring-boot-2.7.6.jar:2.7.6]网址:org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)~[spring-boot-2.7.6.jar:2.7.6]网址:org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)~[spring-boot-2.7.6.jar:2.7.6]网址:com.example.RappersInfo.demo.RappersInfo.main(RapperInfo.java:20)~[classes/:na]位于java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)~[na:na]位于java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)~[na:na]位于java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)~[na:na]位于java.base/java.lang.reflect.Method.ioke(Method.java:568)~[na:na]位于org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)~[spring-boot-devtools-2.7.6.jar:2.7.6]由以下原因引起:org.springframework.boot.web.server.WebServer异常:无法启动嵌入式Tomcat服务器网址:org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229)~[spring-boot-2.7.6.jar:2.7.6]位于org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43)~[spring-boot-2.7.6.jar:2.7.6]位于org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecyclePprocessor.java:178)~[spring-context-5.3.24.jar:5.3.24]省略了19个公共框架由:org.springframework.boot.web.server.WebServerException引起:web应用程序[]中的Servlet[jsp]引发了load()异常网址:org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.load(TomcatEmbedded Context.java:86)~[spring-boot-2.7.6.jar:2.7.6]位于java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOperation.java:183)~[na:na]位于java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)~[na:na]位于java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePiperine.java:762)~[na:na]位于java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePiperine.java:276)~[na:na]位于java.base/java.util.TreeMap$ValueSpliterator.forEachRemaining(TreeMap.java:3215)~[na:na]位于java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)~[na:na]位于java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)~[na:na]在java.base/java.util.stream.ForEachOps$ForEachOp.evalateSequential(ForEachOperation.java:150)~[na:na]在java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evalateSequential(ForEachOperation.java:173)~[na:na]位于java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)~[na:na]位于java.base/java.util.stream.ReferencePipeline.forEach(ReferencePiperine.java:596)~[na:na]网址:org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContextLambda$deferredLoadOnStartup$0(TomcatEmbedded Context.java:64)~[spring-boot-2.7.6.jar:2.7.6]位于org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.doWithThreadContextClassLoader(TomcatEmbedded Context.java:105)~[spring-boot-2.7.6.jar:2.7.6]网址:org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.deferredLoadOnStartup(TomcatEmbedded Context.java:63)~[spring-boot-2.7.6.jar:2.7.6]网址:org.springframework.boot.web.embedded.tomcat.TomcatWebServer.performDeferredLoadOnStartup(TomcatWebServer.java:305)~[spring-boot-2.7.6.jar:2.7.6]网址:org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:216)~[spring-boot-2.7.6.jar:2.7.6]省略了21个公共框架引起原因:javax.servlet.ServletException:Class[org.apache.jasper.servlet.JspServlet]不是servlet网址:org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1072)~[tomcat-embed-core-9.0.69.jar:9.0.69]网址:org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1007)~[tomcat-embed-core-9.0.69.jar:9.0.69]网址:org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.load(TomcatEmbedded Context.java:81)~[spring-boot-2.7.6.jar:2.7.6]省略了37个通用框架由以下原因引起:java.lang.ClassCastException:类org.apache.jasper.servlet.JspServlet无法强制转换为类javax.servlet.servlet(org.apache.japar.servlet.JspServlet和javax.servlets.servlet位于加载程序"app"的未命名模块中)网址:org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1067)~[tomcat-embed-core-9.0.69.jar:9.0.69]39个普通帧省略

这是我的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>2.7.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.RappersInfo</groupId>
<artifactId>demo</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>rappersInfoImage</name>
<description>Demo project for Spring Boot</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>11.0.0-M1</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>glassfish-jstl</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>5.1.3</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-datepicker</artifactId>
<version>1.9.0</version>
</dependency>

<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>11.0.0-M1</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>```

What can i do?
Tried almost everything what was in the internet.
Error happens after changing spring boot version from 3.x. to 2.7.6 (i want to deploy it with war file). Im not sure about my pom.xml. Maybe there is a problem with tomcat dependencies?

如果您的地址或端口不正确/已被使用,则会发生类似的错误。这在大多数情况下都会修复错误,但像上面提到的驱动程序可能会导致错误。

尝试将端口号从8080更改为其他端口号。如果这还不够,那么我遇到的另一个例子如下:

为个人网络接口控制器(NIC)安装了控制软件,允许同时使用以太网和wifi。安装它据说是为了改善游戏体验,但在春季的tomcat游戏中效果不佳。一旦禁用,应用程序就可以按预期运行。其描述如下:

这是一个已安装卡的网络接口Carr驱动程序。根据安装的卡和驱动程序的不同,它会有所不同-您可以通过查看窗口上的设备管理器来查看驱动程序。

希望它能帮助你!!

为个人网络接口控制器(NIC)安装了控制软件,允许同时使用以太网和wifi。安装它据说是为了改善游戏体验,但在春季的tomcat游戏中效果不佳。一旦禁用,应用程序就可以按预期运行。

如果您的地址或端口不正确/已被使用,则会出现类似的错误。这在大多数情况下都会修复错误,但像上面提到的驱动程序可能会导致错误。

禁用游戏服务,或者转到任务管理器并结束游戏服务任务,然后再次运行应用程序。或者重新启动计算机。

在此处输入图像描述

相关内容

  • 没有找到相关文章

最新更新