idea中 Unable to start web server问题
idea中创建springboot项目时,启动程序进行测试时,出现了问题:
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
解决方法一:
在maven的主pom文件中有关springbooot的依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
没有对scope进行设置,默认是provided表示产于编译运行,但不参与打包,打包由生产环境提供。添加complie,启动成功。
解决方法二:
这种是自己的粗心导致,在run方法里面写的是SpringBootApplication,实际应该是SpringBootApplicationMain,与方法名一致。