错误:missing EmbeddedServletContainerFactory bean.

  • Post author:
  • Post category:其他


错误日志:

org.springframework.context.ApplicationContextException:

Unable to start embedded container;

nested exception is org.springframework.context.ApplicationContextException:

Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

分析:

日志说的很清楚,说缺少内嵌servletlet容器工厂

代码:

@Controller

public class Example {




@RequestMapping(value=”/hello”,method= RequestMethod.GET)

public String sayHello(){


return “hello”;

}

public static void main(String[] args) throws Exception {


SpringApplication.run(Example.class, args);

}

}

解决方法:

加入Example类加入注解@SpringBootApplication,具体是@EnableAutoConfiguration 起了作用。



版权声明:本文为freehappyness原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。