Sunday, April 1, 2018

Spring Boot - Cannot determine embedded database driver class for database type NONE

ISSUE:

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

Solution#1:

This problem can be solved by excluding auto-configuration of DataSource in the Spring Boot application class. It can be done using EnableAutoConfiguration annotation as shown in below code.
package com.rizvi.tutorial.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

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

    public static void main(String[] args) {
        SpringApplication.run(SpringBootHelloWorldApplication.class, args);
    }
}
OR,
@SpringBootApplication (exclude = { DataSourceAutoConfiguration.class })
public class SpringBootHelloWorldApplication {
    SpringApplication.run(SpringBootHelloWorldApplication.class, args);
}
By using this configuration, JUnit test case executed fine and no more Cannot determine embedded database driver class for database type NONE error.
Solution#2: =following Fixing by properties file: application.properties
You can add the fallowing line in application.properties file to fix the issue.
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

No comments:

Post a Comment