解決程序啟動(dòng)報(bào)錯(cuò)org.springframework.context.ApplicationContextException: Unable to start web server問題
一、場景
1、該項(xiàng)目在Linux和本機(jī)電腦上啟動(dòng)都正常
2、在另一臺(tái)電腦上啟動(dòng)就報(bào)錯(cuò)
3、代碼都是同一份,沒有差別
二、報(bào)錯(cuò)信息
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依賴時(shí)定義的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> <!--測試時(shí)先注釋該配置--> <!--<scope>provided</scope>--> </dependency>
注:
- 本機(jī)就算是provided也能正常啟動(dòng)
- 另一臺(tái)電腦上就不行
- 應(yīng)該是運(yùn)行環(huán)境上的差異
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- 解決org.springframework.context.ApplicationContextException報(bào)錯(cuò)的問題
- 如何解決Could not transfer artifact org.springframework.boot問題
- 解決IDEA報(bào)錯(cuò)Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded
- SpringBoot引入Redis報(bào)org.springframework.data.redis.core.RedisTemplate類找不到錯(cuò)誤問題
- 程序包org.springframework.boot不存在的問題解決
相關(guān)文章
Spring boot整合Springfox生成restful的在線api文檔
這篇文章主要為大家介紹了Spring boot整合Springfox生成restful在線api文檔,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步2022-03-03Java中RabbitMQ消息隊(duì)列的交換機(jī)詳解
這篇文章主要介紹了Java中的RabbitMQ交換機(jī)詳解,消息隊(duì)列是指利用高效可靠的消息傳遞機(jī)制進(jìn)行與平臺(tái)無關(guān)的數(shù)據(jù)交流,并基于數(shù)據(jù)通信來進(jìn)行分布式系統(tǒng)的集成,是在消息的傳輸過程中保存消息的容器,需要的朋友可以參考下2023-07-07SpringBoot?docker項(xiàng)目部署實(shí)戰(zhàn)
本文主要介紹了SpringBoot?docker項(xiàng)目部署實(shí)戰(zhàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-08-08SpringBoot導(dǎo)出Excel表格到指定路徑的代碼詳解
Spring Boot導(dǎo)出Excel通常涉及到使用第三方庫如Apache POI或者XlsxWriter等,它們能幫助你在Spring應(yīng)用中生成并下載Excel文件,那么SpringBoot如何導(dǎo)出Excel表格到指定路徑,本文將給大家詳細(xì)的介紹一下2024-07-07【Redis緩存機(jī)制】詳解Java連接Redis_Jedis_事務(wù)
這篇文章主要介紹了【Redis緩存機(jī)制】詳解Java連接Redis_Jedis_事務(wù),詳細(xì)的介紹了Jedis事務(wù)和實(shí)例,有興趣的可以了解一下。2016-12-12SpringMvc切換Json轉(zhuǎn)換工具的操作代碼
SpringBoot切換使用goolge的Gson作為SpringMvc的Json轉(zhuǎn)換工具,本文給大家講解SpringMvc切換Json轉(zhuǎn)換工具的操作代碼,感興趣的朋友一起看看吧2024-02-02