解決程序啟動(dòng)報(bào)錯(cuò)org.springframework.context.ApplicationContextException: Unable to start web server問(wèn)題
一、場(chǎng)景
1、該項(xiàng)目在Linux和本機(jī)電腦上啟動(dòng)都正常
2、在另一臺(tái)電腦上啟動(dòng)就報(bào)錯(cuò)
3、代碼都是同一份,沒(méi)有差別
二、報(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依賴(lài)時(shí)定義的scope導(dǎo)致
原依賴(lài)導(dǎo)入配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--是provided導(dǎo)致-->
<scope>provided</scope>
</dependency>四、解決
調(diào)整后依賴(lài)導(dǎo)入配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--測(cè)試時(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ò)的問(wèn)題
- 如何解決Could not transfer artifact org.springframework.boot問(wèn)題
- 解決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類(lèi)找不到錯(cuò)誤問(wèn)題
- 程序包org.springframework.boot不存在的問(wèn)題解決
相關(guān)文章
Java中的CountDownLatch簡(jiǎn)單理解
這篇文章主要介紹了Java中的CountDownLatch簡(jiǎn)單理解,CountDownLatch是一個(gè)同步工具類(lèi),用來(lái)攜調(diào)多個(gè)線程之間的同步,它是是使用一個(gè)計(jì)數(shù)器進(jìn)行實(shí)現(xiàn)的,計(jì)數(shù)器初始值為線程數(shù)量,需要的朋友可以參考下2024-01-01
Spring boot整合Springfox生成restful的在線api文檔
這篇文章主要為大家介紹了Spring boot整合Springfox生成restful在線api文檔,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步2022-03-03
Java中RabbitMQ消息隊(duì)列的交換機(jī)詳解
這篇文章主要介紹了Java中的RabbitMQ交換機(jī)詳解,消息隊(duì)列是指利用高效可靠的消息傳遞機(jī)制進(jìn)行與平臺(tái)無(wú)關(guān)的數(shù)據(jù)交流,并基于數(shù)據(jù)通信來(lái)進(jìn)行分布式系統(tǒng)的集成,是在消息的傳輸過(guò)程中保存消息的容器,需要的朋友可以參考下2023-07-07
SpringBoot?docker項(xiàng)目部署實(shí)戰(zhàn)
本文主要介紹了SpringBoot?docker項(xiàng)目部署實(shí)戰(zhàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-08-08
SpringBoot導(dǎo)出Excel表格到指定路徑的代碼詳解
Spring Boot導(dǎo)出Excel通常涉及到使用第三方庫(kù)如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-12
SpringMvc切換Json轉(zhuǎn)換工具的操作代碼
SpringBoot切換使用goolge的Gson作為SpringMvc的Json轉(zhuǎn)換工具,本文給大家講解SpringMvc切換Json轉(zhuǎn)換工具的操作代碼,感興趣的朋友一起看看吧2024-02-02

