本文已参与「新人创作礼」活动,一起开启掘金创作之路。
1、错误信息
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.
2、解决方案
(1)检查在main方法所在的类是否添加@SpringBootApplication注解
(2)检查在pom.xml是否添加依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
如果以上都没有错误,检查测试代码是否正确
@SpringBootApplication
public class SpringBootSelfApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootSelfApplication.class, args);
}
}
出现以下信息表示测试成功!