解決程序啟動報錯org.springframework.context.ApplicationContextException: Unable to start web server問題
一、場景
1、該項目在Linux和本機電腦上啟動都正常
2、在另一臺電腦上啟動就報錯
3、代碼都是同一份,沒有差別
二、報錯信息
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:157)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.xxx.RobotManagerSvr.main(RobotManagerSvr.java:32)
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:206)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154)
... 8 common frames omitted
三、原因
導(dǎo)入spring-boot-starter-tomcat依賴時定義的scope導(dǎo)致
原依賴導(dǎo)入配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--是provided導(dǎo)致-->
<scope>provided</scope>
</dependency>四、解決
調(diào)整后依賴導(dǎo)入配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--測試時先注釋該配置-->
<!--<scope>provided</scope>-->
</dependency>注:
- 本機就算是provided也能正常啟動
- 另一臺電腦上就不行
- 應(yīng)該是運行環(huán)境上的差異
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
- 解決org.springframework.context.ApplicationContextException報錯的問題
- 如何解決Could not transfer artifact org.springframework.boot問題
- 解決IDEA報錯Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded
- SpringBoot引入Redis報org.springframework.data.redis.core.RedisTemplate類找不到錯誤問題
- 程序包org.springframework.boot不存在的問題解決
相關(guān)文章
Spring Cloud應(yīng)用實現(xiàn)配置自動刷新過程詳解
這篇文章主要介紹了Spring Cloud應(yīng)用實現(xiàn)配置自動刷新過程詳解,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-12-12
SpringBoot實現(xiàn)redis延遲隊列的示例代碼
延時隊列場景在我們?nèi)粘I(yè)務(wù)開發(fā)中經(jīng)常遇到,它是一種特殊類型的消息隊列,本文就來介紹一下SpringBoot實現(xiàn)redis延遲隊列的示例代碼,具有一定的參考價值,感興趣的可以了解一下2024-02-02
Java實現(xiàn)兩人五子棋游戲(五) 判斷是否有一方勝出
這篇文章主要為大家詳細介紹了Java實現(xiàn)兩人五子棋游戲,判斷是否有一方勝出,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-03-03
java遍歷http請求request的所有參數(shù)實現(xiàn)方法
下面小編就為大家?guī)硪黄猨ava遍歷http請求request的所有參數(shù)實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-09-09

