概述
今天在做项目的时候,使用embded tomcat启动SpringBoot项目时,idia报错:Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
出错点排查
使用本地tomcat运行项目发现没问题,但使用嵌入式tomcat就报上述错。
我项目中embded tomcat导入方式为:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>test</scope>
</dependency>
解决方案
查找资料并测试后,发现将<scope>
改为provided
,问题解决:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>