Failed to configure a DataSource:'url' attribute is not specified and no embedded datasource could be configured.
Failed to configure the data source: The url
attribute was not specified, and the embedded data source could not be configured.
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-03 09:47:45.300 ERROR 23160 --- [ main] 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).
Spring boot will load the org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
class by default. The DataSourceAutoConfiguration
class uses the @Configuration
annotation to inject the dataSource bean
into spring. Because there is no configuration information related to dataSource
in the project, an error will be reported when spring creates a dataSource bean
due to lack of relevant information.
1 Add to the Application class
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
2 Configure the data source:
For example, in the application configuration file:
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://ip:[port number]/[database name]?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8