无法启动web服务器;嵌套异常是java.lang.NoSuchFieldError:ALLOW_ENCODED_SLA



在启动主弹簧启动应用程序时,我在弹簧启动项目中遇到了这个问题

我得到这个错误日志:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[30m2022-03-25 16:07:49,833[0;39m [1;31mERROR[0;39m [[34mrestartedMain[0;39m] [33morg.springframework.boot.SpringApplication[0;39m: Application run failed
org.springframework.context.ApplicationContextException: **Unable to start web server; nested exception is java.lang.NoSuchFieldError: ALLOW_ENCODED_SLASH**
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
at com.elsevier.rrexport.RRDecopuledExportApplication.main(RRDecopuledExportApplication.java:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.NoSuchFieldError: ALLOW_ENCODED_SLASH
at org.apache.catalina.connector.Connector.<init>(Connector.java:271)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:200)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160)
... 13 common frames omitted

请告诉我,我需要更改什么配置。我已经添加了:

System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");

也在application.properties中定义了它:

org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

似乎什么都不管用。我的建筑.gradle

您使用的是Tomcat模块的混合。有些来自Tomcat 10,有些来自Tomcat 9。与其在build.gradle文件中手动设置版本,不如允许Spring Boot的依赖项管理来控制Tomcat版本。这将确保您使用的Tomcat版本与您正在使用的Spring Boot版本兼容,并确保所有Tomcat模块都具有相同的版本。

请注意,SpringBoot2.x与Tomcat10不兼容。Tomcat10是Servlet 5.0规范的实现,Servlet 5.0规范是Jakarta EE 9的一部分。要使用Tomcat10,您必须使用Spring Boot 3,它目前仅作为里程碑提供,直到2022年底才会发布。

相关内容

  • 没有找到相关文章

最新更新