问题:
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


原代码:

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



相关文章:

  • 2021-09-16
  • 2022-01-18
  • 2021-06-29
  • 2021-10-26
  • 2021-09-07
  • 2022-12-23
猜你喜欢
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
相关资源
相似解决方案