为了账号安全,请及时绑定邮箱和手机立即绑定

由于缺少 ServletWebServerFactory bean,无法启动 ServletWeb

由于缺少 ServletWebServerFactory bean,无法启动 ServletWeb

胡说叔叔 2023-09-27 16:10:05
使用 Jetty-starter,由于以下错误,我无法启动 Spring Boot 应用程序:20:23:51.548 [main] ERROR o.s.boot.SpringApplication - Application run failedorg.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]    ... 8 common frames omitted> Task :bootRun FAILED怎么解决这个问题呢?
查看完整描述

1 回答

?
隔江千里

TA贡献1906条经验 获得超10个赞

答案是 Spring jetty 启动器无法按预期工作,您必须添加依赖项。


删除启动器,然后像这样添加它们: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.+’

}


查看完整回答
反对 回复 2023-09-27
  • 1 回答
  • 0 关注
  • 61 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信