Spring Boot 学习第三章(异常处理)

一.SpringBoot 与Mabytis 整合启动出现的异常

具体异常下面 :
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:189) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
... 13 common frames omitted

我参考了几篇博客大概解释是:
Spring Boot启动出现错误,错误内容大概的意思是:未能加载嵌入的供web应用加载的空间,是因为缺少EmbeddedServletContainerFactory bean。
解决方案:
在stackflow上面看到了这个错误的解决办法,原文如下:
The scheduling guide isn't a web app so you probably have some mouldy stuff in your pom.xml from the REST guide? If you follow the instructions closely it should work. Another potential issue with the code you posted above is that your  @EnableAutoConfiguration class is not used in the context, only as a main method (which may not be a problem for the scheduling guide but it probably is for a bunch of others).
也就是说解决的办法是在SpringBoot启动类上加一个@EnableAutoConfiguration注解,但是毕竟是Spring Boot啊,只需要一个@SpringBootApplication注解即可搞定,因为@SpringBoootApplication注解已经带了 @EnableAutoConfiguration注解

最后解决方案如图:


参考博客:



二 第二部启动错误

错误内容:
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-04-25 20:39:13.930 ERROR 7264 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :

***************************
APPLICATION FAILED TO START
***************************

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "dev" are currently active).

百度翻译一下 内容如下

解决方法:
其实 总结下就是没有 配置数据源 ,去检查下项目application.properties是否配置 数据源。
具体解决如下图:

猜你喜欢

转载自blog.csdn.net/lgd_guangdong/article/details/80085751