spring-boot - 应用程序通过 Spring Boot Run 而不是通过 Intelli

我在通过命令行运行我的 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,但如果是这种情况,那么应用程序也不应该通过命令行启动)

所以,我在那里找不到任何答案。

最佳答案

当您将 Tomcat 的依赖范围设置为“已提供”,但在运行该应用程序时,您没有选择“包括已提供范围的依赖项”选项时,可能会发生此错误。

您可以在应用的运行配置下选择该选项。

在一些旧版本的 IntelliJ 中,您可能会看到一个复选框来启用它。

关于spring-boot - 应用程序通过 Spring Boot Run 而不是通过 IntelliJ Idea 运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69716668/

相关文章:

r - 在 download.file 中关闭 SSL 验证

julia - 如何在 Julia 中生成随机日期?

prototyp">javascript - 在 javascript "contructor --> prototyp

typescript - 类型错误 : EventEmitter is not a construc

r - 如何在 ifelse 中设置 FALSE 条件以使其保持原始值

java - 将 Enum 类名本身作为 String 获取的最佳方法

c++ - std::vector 和 move 语义

typescript - 如何从Nuxt 3服务器获取路由参数

html - 是否可以使用纯 CSS 为仅包含一个元素的列表设置样式,而不是为包含多个元素的列表设置

unity3d - Unity Vertical Layout Group 高度不计算子项