Saturday, 29 October 2022

How to Fix the "Cannot Determine Embedded Database Driver Class for Database Type NONE" Exception in Spring Boot

       I published my last blog post about a year ago. I apologize to my readers for the long gap in posting due to some personal reasons.

Today, we'll discuss a common issue that you may encounter when starting a Spring Boot application without configuring a database.

If you are a Spring Boot beginner and try to run your application without configuring a datasource, you may encounter the following exception:

*************************** APPLICATION FAILED TO START *************************** 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). - [report:42] - [] - []

The above issue we can solve in two ways as follows,

1) Fixing with application.properties file

you can add the fallowing line in application.properties file,

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration


2) Fixing with Configuration code

You can exclude DataSourceAutoConfiguration by using the @EnableAutoConfiguration annotation, as shown below:

@SpringBootApplication
@EnableAutoConfiguration (exclude = { DataSourceAutoConfiguration.class })
public class SpringbootApplication {
	SpringApplication.run(SpringbootApplication.class, args);
}

Or, you can also add the exclusion directly to the @SpringBootApplication annotation itself.

@SpringBootApplication (exclude = { DataSourceAutoConfiguration.class })

public class SpringbootApplication {
	SpringApplication.run(SpringbootApplication.class, args);
}

Thank you for visiting blog.

3 comments:

  1. SAP S/4HANA provides businesses with a wide range of collaboration options that can help them streamline their operations, reduce costs, and improve customer satisfaction. From procurement and finance to supply chain and sales, SAP S/4HANA offers a comprehensive set of collaboration tools that can help businesses stay ahead of the competition and drive growth in the digital age. For more information, visit our website SAP Consulting Services or call us @ 1-289-952-8845.

    ReplyDelete
  2. Nice Post, will be very helpful for me. Thanks for sharing.
    Interviewhabit

    ReplyDelete
  3. Nice... very informative article, keep posting

    ReplyDelete