今天搭了个springboot的小demo,但是启动的时候报了这个错误:
scription:
Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-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.
1.分析:在新建项目的时候我添加了mysql组件,但是我还没配置数据源
2.解决方案:
在启动类的@EnableAutoConfiguration
或@SpringBootApplication中添加exclude= {DataSourceAutoConfiguration.class},
排除此类的autoconfig。
即:@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
3.重新启动以后就可以正常运行。