我刚刚在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
答案 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;
}