Spring Boot - Cannot determine embedded database driver class for database type NONE
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Spring Boot is a powerful framework designed to streamline Java applications, particularly for building microservices. One of its convenient features is the ability to automatically configure an embedded database. However, developers occasionally encounter the error message: "Cannot determine embedded database driver class for database type NONE." Understanding this error and how to resolve it is crucial for seamless application development.
Overview of the Error
When you run a Spring Boot application, it attempts to determine the appropriate database driver to use. This process is part of Spring Boot's auto-configuration capabilities. If it encounters the error "Cannot determine embedded database driver class for database type NONE," it means Spring Boot cannot deduce which embedded database to use because none is specified or several configurations are missing.
Causes of the Error
- Missing Dependency: If you have not included the necessary database dependency in your
pom.xmlorbuild.gradle, Spring Boot cannot instantiate a default embedded database. - Incorrect Configuration: There could be an error or omission in your
application.propertiesorapplication.ymlfile that prevents the appropriate determination of the database type. - No DataSource Bean: If an explicit
DataSourcebean is not configured when opting for an external database, Spring Boot may still try—and fail—to configure an embedded database. - Application Context Issues: Incorrect application context setup might inadvertently suppress the auto-configuration mechanism.
Analyzing the Problem
When confronted with the "Cannot determine embedded database driver class for database type NONE" error, a systematic approach can help identify its cause and rectify it.
Step-by-Step Resolution
- Check Dependencies:Ensure that the appropriate database dependencies are included. For example, for an H2 database, your
pom.xmlshould include:
Similarly, for Gradle, include:
- Verify Configuration Files:Check
application.propertiesorapplication.ymlfor correct database configurations. For instance:
Any misconfiguration here can prevent the application from starting correctly.
- Define DataSource Bean Explicitly:If using a non-embedded database, explicitly define the DataSource bean in a configuration class:
- Enable or Disable Auto-Configuration:Use
@EnableAutoConfigurationor selectively exclude configurations that interfere with your desired setup:
Additional Considerations
Embedded vs. External Databases
- Embedded Databases: These are lightweight, included with the application during runtime, like H2, HSQLDB, or Derby. They are suitable for development and testing.
- External Databases: Solutions like MySQL, PostgreSQL, etc., require explicit configuration and are used in production environments for persistence.
Spring Profiles
Use Spring Profiles to differentiate configurations for various environments (development, testing, production). This approach helps manage different database setups through profile-specific configuration files:
Testing Database Configuration
Testing your database configuration is crucial to ensure proper connections. Utilize Spring Boot's testing support by writing integration tests to validate your data layer:
Summary Table
| Key Aspect | Description |
| Cause | Missing or incorrect database configuration |
| Embedded Database Examples | H2, HSQLDB, Derby |
| Dependency Management | Ensure correct database drivers in pom.xml or build.gradle |
| Configuration Files | Verify application.properties or application.yml for correct settings |
| Bean Configuration | Define DataSource bean explicitly if necessary |
| Auto-Configuration Management | Use @EnableAutoConfiguration judiciously or exclude as needed |
| Environment Specific Settings | Utilize Spring Profiles for environment-specific configurations |
| Testing | Write integration tests to validate database setup |
Resolving the "Cannot determine embedded database driver class for database type NONE" error involves ensuring correct configuration, dependencies, and understanding Spring Boot's auto-configuration behavior. Taking a methodical approach helps maintain application reliability and performance across different environments and database types.

