错误日志:
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 起了作用。