:: Spring Boot :: (v2.0.7.RELEASE)
2019-08-27 11:31:57.774 ERROR 15364 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
解析:
搭建基于SpringBoot ,springCloud 框架简单入门 的测试。报错如上:
原因:
这是因为添加了数据库组件,所以autoconfig会去读取数据源配置,而新建的项目还没有配置数据源/URL地址错误,所以会导致异常出现。
解决方案:
一。 在启动类的@EnableAutoConfiguration或@SpringBootApplication中添加exclude = {DataSourceAutoConfiguration.class},排除此类的autoconfig。启动以后就可以正常运行。
1 @MapperScan("com.wsc.core.mapper")//映射mapper地址 2 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) //启动类 SpringBoot 3 public class Start { 4 public static void main(String[] args) { 5 SpringApplication.run(Start.class,args); 6 } 7 }
二。application.yml中的URL地址识别不出来,格式写错。
yaml格式文件的写入 要求严格 (等阶平齐,顶格输入)
yml文件