springboot 项目启动报错 url' attribute is not specified and no embedded datasource could be configured

报错信息:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-08-06 10:04:25.845 ERROR 11256 --- [ 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).

原因:由于添加了数据库组件,所以autoconfig会去读取数据源配置,新建的项目还没有配置数据源,所以会导致异常出现。

解决办法:
在启动类添加如下内容
即:@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

猜你喜欢

转载自blog.csdn.net/wsjzzcbq/article/details/81449607