java - Spring/Java11 - 由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext
问题描述
这似乎是一个反复出现的问题,但似乎没有一个解决方案对我有用。我有一个要升级到的 Spring 应用程序JDK11
。我的gradle
构建运行良好,但下面是bootRun.
我在某处缺少步骤的结果吗?
错误
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-06-04 11:33:38.718 ERROR 17220 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) ~[spring-context-5.2.10.RELEASE.jar:5.2.10.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at com.org.app.NewApplication.main(NewApplication.java:15) ~[main/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:205) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:177) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:158) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
... 9 common frames omitted
代码
@EnableGlobalMethodSecurity(securedEnabled = true)
@SpringBootApplication
public class NewApplication extends SpringBootServletInitializer {
public static void main(String[] args)
{
SpringApplication.run(NewApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(NewApplication.class);
}
}
摇篮构建
plugins {
id 'org.springframework.boot' version '2.3.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'com.github.ben-manes.versions' version '0.33.0'
id 'org.sonarqube' version '3.0'
id 'org.owasp.dependencycheck' version '3.1.2'
id 'java'
id 'checkstyle'
id 'project-report'
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web') {
exclude module: 'spring-boot-starter-tomcat'
}
compile 'org.springframework.boot:spring-boot-configuration-processor'
compile 'org.springframework.boot:spring-boot-starter-validation'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.boot:spring-boot-starter-mail'
compile 'org.springframework.security:spring-security-config'
compile 'org.springframework.session:spring-session-jdbc'
...
解决方案
推荐阅读
- python - 滑块寻找位置 pygamemixer
- complex-event-processing - 我想自动触发脚本,无需点击输入,也无需按 Enter
- sql - 减少多值连接 SQL 查询中的重复记录
- java - 如何解决Java“嵌套循环”问题?
- c# - 尝试在 Program Files 中安装 Configuration.Save() 时访问被拒绝
- heroku - Heroku 域路由 - www 有效,没有失败
- c# - C# 构造函数不接受子类型字典
- python - 如何将原始查询集转换为查询集?
- apache-kafka - 初始化 TEST 连接器后雪花卡夫卡连接器失败
- python - 如何从嵌套循环中获取变量?