java:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Failed to determine a suitable driver class

***************************

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).

解决办法:

1 @SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

   如果是多个:修改成@SpringBootApplication(exclude = {MongoAutoConfiguration.class, DataSourceAutoConfiguration.class})

2 上诉修改不生效:可能的原因是idea没有指定resource目录,导致启动时没读取到配置文件

   方法:右击resource文件夹 -> MarkDirectory as ->Sources Root

两种方法都试过了,第二个方法成功解决问题

  

猜你喜欢

转载自www.cnblogs.com/singlelcx/p/11528570.html