spring boot idea 启动异常

阅读更多
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.



解决方案

在经过多次尝试,几乎要放弃的时候,突然想到一个问题,会不会是因为Intellij集成maven引入jar包时scope设置的问题。

仔细检查pom文件,发现问题可能出现在一下两个地方:


      org.springframework.boot
      spring-boot-starter-tomcat
      1.2.3.RELEASE
      provided
   

   
      org.apache.tomcat.embed
      tomcat-embed-jasper
      7.0.68
      provided
   


注释掉两个配置中的

provided

问题就这么解决了。

总结

这可能是Intellij的一个bug,在使用spring-boot的时候,如果把某个引入的依赖设置为provided,那么在Intellij启动时就会找不到相应的类。因此,此时需要把此项配置给注释掉,但是打包上线的时候并不需要这些依赖,那么在打包的时候就把注释打开,即可。

已经遇到两次相同的问题,谨记!

你可能感兴趣的:(spring boot idea 启动异常)