Cannot determine embedded database driver class for database type NONE – Spring Boot Problem

1
1744

When i was beginner in Spring boot and most of time i got many error to run my first application successfully. And one of the error given below:

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

Solution:

You haven’t provided Spring Boot with enough information to auto-configure a DataSource. To do so, you’ll need to add some properties to application.properties with the spring.datasourceprefix. Take a look at DataSourceProperties to see all of the properties that you can set.

We have three ways to solve this:

Exclude Data source

If you don’t need any data source, just exclude it as below:

@SpringBootApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class SpringBootDemoApplication { }

Using Pom.xml

If you need ds just for test purpose, say using an embedded DB like HSqldb, just add the dependency in your pom or yml file:

<dependency>
 <groupId>org.hsqldb</groupId>
 <artifactId>hsqldb</artifactId>
 <scope>runtime</scope>
</dependency>

Using application.properties

You want to have your own external DB configuration, you need to provided DS information in spring boot configuration file, generally add below into application.properties is fine.

You’ll need to provide the appropriate url and driver class name:

#MySQL Connection settings
spring.datasource.url=jdbc:mysql://localhost:3306/mysql_database_name
spring.datasource.username=mysql_username
spring.datasource.password=mysql_password
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.datasource.* is the default prefix for spring boot data source configuration, if you use other prefix, you may need add your own ds configuration file.

 

 

 

Share your thoughts

1 COMMENT

Loading Facebook Comments ...
Loading Disqus Comments ...