Spring Boot jdbc问题。无法配置数据源:未指定'url'属性,并且无法配置任何嵌入式数据源

时间:2019-05-28 18:20:44

标签: java spring spring-boot

我刚刚在Intellij IDEA中连接了该数据库,这很好,但是当我使用此配置启动Spring Boot应用程序时,我看到了此故障的消息

***在图片上配置

2019-05-28 20:56:53.487 ERROR 700 --- [  restartedMain] 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).


Process finished with exit code 0

application.properties pom

1 个答案:

答案 0 :(得分:0)

我们需要在配置类中为DataSource添加一个bean

@Bean
public DataSource dataSource(){
    DriverManagerDataSource source = new DriverManagerDataSource();
    source.setDriverClassName(driverClass);
    source.setUrl(url);
    source.setUsername(username);
    source.setPassword(password);
    return source;
}