【发布时间】:2021-12-11 10:43:35
【问题描述】:
当我通过命令行运行我的 Spring Boot 应用程序时,我遇到了这个问题
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=dev -Dserver.port=8083"
这工作正常,但在 intellij 中作为应用程序运行时出现以下错误 -
Application run failed,
exc.stack=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.\n\tat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
可能的原因是什么,我应该在哪里查看配置修复?
关于这个模式还有其他问题,但都没有提到错误-
Spring Boot application runs fine via Maven but not via IDE Intellij IDEA
ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean (对于缺少 servlet bean,但如果是这种情况,那么应用程序也不应该通过命令行启动)
所以,我在那里找不到任何答案。
【问题讨论】:
-
你检查过这个帖子吗? stackoverflow.com/questions/50231736 好像类似
-
@KonstantinAnnikov 是的,我也附上了这个有问题的链接。
标签: spring-boot maven intellij-idea