Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServer

问题:
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.


Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServer_第1张图片


原代码:

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即可。

运行结果:

Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServer_第2张图片



你可能感兴趣的:(springboot)