簡體   English   中英

通過 Spring Boot Run 但不通過 IntelliJ Idea 運行的應用程序

[英]Application Running via Spring Boot Run but not via IntelliJ Idea

我面臨的問題是,當我通過命令行運行 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 應用程序通過 Maven 運行良好,但不能通過 IDE Intellij IDEA

ApplicationContextException: Unable to start ServletWebServerApplicationContext 由於缺少 ServletWebServerFactory bean (對於缺少 servlet bean,但如果是這種情況,那么應用程序也不應該通過命令行啟動)

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

當您將 Tomcat 的依賴項范圍設置為“提供”時,可能會發生此錯誤,但在運行應用程序時,您沒有選擇“包含提供范圍內的依賴項”選項。

您可以在應用程序的運行配置下選擇該選項。

在某些舊版本的 IntelliJ 中,您可能會看到一個復選框來啟用它。

運行配置 IntelliJ 中的選項

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM