问题:
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
原代码:
SpringbootDemoApplication启动类:
@SpringBootApplication public class SpringbootDemoApplication { public static void main(String[] args) { SpringApplication.run(HelloController.class, args); } }
HelloController类:
@RestController public class HelloController { @RequestMapping(value = "sayhello", method = RequestMethod.GET) public String sayhello() { return "Hello SpringBoot !"; } }
解决方案:
HelloController加上注解@EnableAutoConfiguration即可。
运行结果: