Learn springboot today and use idea to create projects. Mysq was added when selecting the component, and an error was reported when it was started for the first time. The error message is as follows:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to auto-configure a DataSource: ‘spring.datasource.url’ is not specified and no embedded datasource could be auto-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).
After multi-party verification, you need to add exclude in the @EnableAutoConfiguration or @SpringBootApplication of the startup class
= {DataSourceAutoConfiguration.class}, exclude this type of autoconfig. After starting, it can run normally.
This is because the database component is added, so autoconfig will read the data source configuration, and my newly created project has not yet configured the data source, so an exception will occur.
Solution to the problem 2: No need to change the adding statement, pay attention to the correctness of the project file structure