Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasou
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).
在学习java的过程中,发现如上问题,
解决:Mybatis没有找到合适的加载类,可以根据上述日志发现spring-datasourse-url没有加载成功。
在@@SpringBootApplication注解上加上exclude,解除自动加载DataSourceAutoConfiguration.class
`import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
@SpringBootApplication(exclude=DataSourceAutoConfiguration.class)
public class StoreApplication {
DataSourceProperties sdp;
public static void main(String[] args) {
SpringApplication.run(StoreApplication.class, args);
}
}`