Reasons for IDEA startup failure

When IDEA starts the spring project, the error content is as follows.


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


Insert picture description here
There are two solutions, one is to add an annotation to the head of the startup class. It is
not recommended to do this, so that the database table structure cannot be automatically updated if it is done.

@SpringBootApplication(exclude= {
    
    DataSourceAutoConfiguration.class})

The second is to really solve the cause of this problem.
There are many reasons for this.
One may be that your configuration is not matched. The
Insert picture description here
other is that the driver class of the database is not available.
Check whether there is a driver class in pom.xml Configuration
For example, my configuration is

	<dependencies> 
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>runtime</scope>
		</dependency>
	</dependencies> 

Then in IDEA, update the configuration, maven will automatically download the jar package of the driver class.
Insert picture description here
I wish you success

Guess you like

Origin blog.csdn.net/phker/article/details/111662150