最近在项目里,在进行测试的时候报了个:
java.lang.IllegalStateException: Failed to load ApplicationContext
Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
不是技术论坛中大家常说的应用入口类缺少@SpringBootApplication标注,或者是Spring bean缺少@EnableAutoConfiguration标注等问题。
还可能是在你的项目里,你的项目是排除了Springboot的tomcat(想用自己的嘛)
但是在test方式启动时就会报以上错误,所以需要将排除注释掉,其余的方案我还没找到
<!--SpringBoot 要集成 SpringMVC 进行 Controller 的开发,所以项目要导入 web 的启动依赖。-->
<!-- 继承父工程 spring-boot-starter-parent 启动器后,子工程的启动器版本无需再指定 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!--<exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId>-->
<!-- </exclusion>-->
<!--</exclusions>-->
</dependency>