新建springboot项目启动出错 Failed to configure a DataSource: 'url' attribute is not specified and no embedde

错误信息入下:
...
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).
分析原因:
导入了spring-boot-starter-jdbc模块但是没有配置四大参数
解决起来也不难,要么配置,要么不用。

解决办法:

1.去掉数据库依赖

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class BdservoApplication {
public static void main(String[] args) {
SpringApplication.run(BdservoApplication.class, args);
}
}
3.前面两种方案都是项目不用数据库的情况下,如果用数据库还报这个错基本就是四大参数没配置:
server.port=8888
spring.database.driver-class-name=com.mysql.Driver
spring.database.url=jdbc:mysql://localhost:3306?bike?
useUnicode=true&characterEncoding=utf-8
spring.database.username=root
spring.database.password=123568

解决!

你可能感兴趣的:(新建springboot项目启动出错 Failed to configure a DataSource: 'url' attribute is not specified and no embedde)