简体   繁体   English

Jetty 9 + Spring 引导 - 由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext

[英]Jetty 9 + Spring Boot - Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean

With Jetty-starter, I was not able to launch a Spring Boot application due to this error:使用 Jetty-starter,由于此错误,我无法启动 Spring 引导应用程序:

20:23:51.548 [main] ERROR 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:156) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    at xxxxxxxx.MyApplication.main(MyApplication.java:18) [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:203) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153) ~[spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
    ... 8 common frames omitted

> Task :bootRun FAILED

How to solve this?如何解决这个问题?

The answer is that Spring jetty starter does not work as expected and you have to add your dependencies.答案是 Spring jetty starter 无法按预期工作,您必须添加依赖项。

Remove the starter, and add them like this post: https://medium.com/code-your-life/use-jetty9-with-spring-boot-and-gradle-85a1127c919f删除启动器,然后像这样添加它们: https://medium.com/code-your-life/use-jetty9-with-spring-boot-and-gradle-85a1127c919f

dependencies{
  compile(“org.springframework.boot:spring-boot-starter-web”) {
    exclude module: “spring-boot-starter-tomcat”
  }
  compile ‘org.eclipse.jetty:jetty-webapp:9.+’
  compile ‘org.eclipse.jetty:jetty-jsp:9.+’
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由于缺少ServletWebServerFactory bean,无法启动ServletWebServerApplicationContext - Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean spring-boot web 应用程序启动失败:由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext - spring-boot web app fails to start : Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean 无法在Tomcat7上运行Spring Boot 2.0:“由于缺少ServletWebServerFactory bean,因此无法启动ServletWebServerApplicationContext。” - Cannot run Spring Boot 2.0 on Tomcat7: “Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.” Spring 启动 maven 项目由于缺少 ServletWebServerFactory bean 无法启动 ServletWebServerApplicationContext - Spring Boot maven project unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean Spring boot 测试失败说,由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext - Spring boot Test fails saying, Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean 无法启动 web 服务器; 由于缺少 ServletWebServerFactory bean,嵌套异常是无法启动 ServletWebServerApplicationContext - Unable to start web server; nested exception is Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean org.springframework.context.ApplicationContextException 由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext - org.springframework.context.ApplicationContextException Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean 由于缺少ServletWebServerFactory bean,即使使用@springbootapplication,我也无法启动ServletWebServerApplicationContext - I am getting Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean even with @springbootapplication 由于缺少 ServletWebServerFactory,无法启动 Web 服务器 - Unable to start web server due to missing ServletWebServerFactory Spring boot -- 由于缺少 EmbeddedServletContainerFactory bean 无法启动 EmbeddedWebApplicationContext - Spring boot -- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM