spring-boot 启动报错 Failed to auto-configure a DataSource

版权声明:本文为博主原创文章,未经博主允许不得转载。https://www.jianshu.com/writer#/notebooks/24800983/notes/27191787

报错内容:

Description:
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.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

报错原因:

由于idea项目在初始化spring initializr时,勾选了数据库,但是项目在刚开始的时候还没建立数据库,所以spring boot找不到数据库配置报错。

临时解决方案:

查阅其他大神博客后
在项目启动类的@SpringBootApplication中添加
exclude={DataSourceAutoConfiguration.class}

文章参考:

https://blog.csdn.net/daxiang52/article/details/79420777

你可能感兴趣的:(spring-boot 启动报错 Failed to auto-configure a DataSource)