SpringBoot 服务启动的时候报错Application run failed

SpringBoot 服务启动的时候报错Application run failed:

(1)application.yml文件格式错误,编辑的时候是根据提示默认推荐gbk的格式,

百度后一般都说是是配置文件的布局格式问题,后来再次打开后文件里的注释会乱码

后来将格式转成UTF-8后就好了,这种问题真的是好坑。。。

(2)启动过程中的时候报:

2019-02-22 15:50:50.187 ERROR 11880 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

 

了解了后是因为需要在启动类的中添加@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}),排除此类的autoconfig。

了解了下为什么要在启动的时候去做一个排除:

springboot很多依赖插件是有依赖时,就会读取相关配置,如果读取不到,就会使用默认的,可能会报错,但是又在项目中不好排除就可以使用 @EnableAutoConfiguration 注解。启动的时候就不会去读取这些配置了。


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