BeanCreationException: Database Type NONE MySQL Fix

By HeadsNTail Published 13 min read MySQL
BeanCreationException: Database Type NONE MySQL Fix

You can fix this Spring Boot database startup failure in about 10 minutes by correcting the JDBC configuration and checking that the MySQL driver is available.

The error usually appears as:

org.springframework.beans.factory.BeanCreationException:
Cannot determine embedded database driver class for database type NONE.
If you want an embedded database please put a supported one on the classpath.

A missing spring.datasource.url is the most common configuration mistake.

A missing MySQL JDBC driver can also prevent Spring Boot from creating a working database connection.

Another frequent cause is placing valid database settings in a configuration file or Spring profile that isn't being loaded.

Quick answer: The error beancreationexception: cannot determine embedded database driver class for database type none means Spring Boot couldn't determine which JDBC driver to use while creating its DataSource. Add the MySQL connection URL, username, password, and Connector/J dependency. Then check that the correct application configuration and Spring profile are active.

Quick fix: BeanCreationException: Cannot determine embedded database driver class for database type NONE

Start with the application's database configuration. This resolves the problem when Spring Boot is missing the JDBC connection details.

Step 1: Configure MySQL in application.properties

Open:

src/main/resources/application.properties

Add these settings:

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/appdb
spring.datasource.username=appuser
spring.datasource.password=your_password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

Replace:

  • 127.0.0.1 with your MySQL server address.
  • 3306 with the configured MySQL port.
  • appdb with your existing database name.
  • appuser and your_password with valid database credentials.

These are example values, not credentials that will work automatically.

For production, keep passwords outside source control and supply them through your deployment's secret or environment configuration.

Spring Boot can normally determine the MySQL driver from a valid JDBC URL. The explicit driver-class-name setting is useful for troubleshooting, but isn't usually required.

The important property is:

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/appdb

Without that URL, Spring Boot may attempt to find an embedded database instead.

This behavior is documented in the Spring Boot SQL database configuration reference.

Step 2: Add the MySQL JDBC dependency

Open your Maven project's pom.xml.

For a Spring Boot project using its supported dependency management, add:

<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
    <scope>runtime</scope>
</dependency>

Place it inside the existing <dependencies> section.

Spring Boot's dependency management supplies the compatible version when your project uses its managed dependency definitions.

If your project doesn't use Spring Boot dependency management, you'll need to specify a Connector/J version compatible with your Java and MySQL setup.

For Gradle projects using Groovy DSL, add this to build.gradle:

dependencies {
    runtimeOnly 'com.mysql:mysql-connector-j'
}

For Gradle Kotlin DSL (build.gradle.kts):

dependencies {
    runtimeOnly("com.mysql:mysql-connector-j")
}

Use the syntax matching your build file. You don't need both.

Step 3: Restart Spring Boot

From the project directory, run:

./mvnw clean spring-boot:run

On Windows PowerShell:

.\mvnw.cmd clean spring-boot:run

These commands assume the project includes the Maven Wrapper and Spring Boot Maven plugin.

For Gradle:

./gradlew bootRun

If the application connects successfully, its startup log should proceed past DataSource initialization.

You may see Hikari connection pool initialization or Hibernate startup messages, depending on the project's dependencies.

If the error changes to Access denied, Unknown database, or Communications link failure, that's useful information. The driver-selection problem may be fixed, and you're now seeing an actual connection problem.

Why Spring Boot cannot determine the embedded database driver

The message sounds like MySQL doesn't support the requested database type. That's not what it means.

NONE is an internal Spring Boot database-type value used in the older error message. It indicates that Spring couldn't identify a supported embedded database during its DataSource configuration.

Spring Boot can automatically configure databases when it has enough information.

For an external MySQL database, it needs a valid JDBC URL and a usable driver.

For an embedded database, it needs an appropriate embedded database dependency, such as H2 or HSQLDB.

When neither path can be configured correctly, DataSource creation fails.

This can happen before the application sends a single SQL query to MySQL.

That's also why changing table definitions, SQL queries, or Hibernate mappings usually won't solve this particular startup error.

Cause 1: Missing spring.datasource.url in application.properties

How to confirm

Inspect:

src/main/resources/application.properties

Look for this exact property:

spring.datasource.url=

If it's missing, empty, or incorrectly named, Spring Boot may not receive the connection URL.

For example, this is not a standard Spring Boot DataSource property:

database.url=jdbc:mysql://127.0.0.1:3306/appdb

Spring Boot won't automatically treat database.url as spring.datasource.url.

How to fix

Use the expected prefix:

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/appdb
spring.datasource.username=appuser
spring.datasource.password=your_password

If you prefer YAML, open:

src/main/resources/application.yml

Then configure:

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/appdb
    username: appuser
    password: your_password
    driver-class-name: com.mysql.cj.jdbc.Driver

Don't put these settings under spring.jpa or spring.hibernate.

Those sections handle different database-related configuration.

Also check the file location. A file accidentally placed under src/main/resources/static isn't treated as the normal application configuration file.

Cause 2: MySQL JDBC driver not found in the classpath

A correct database URL doesn't help if the MySQL connector isn't available at runtime.

Depending on your Spring Boot version and configuration, the application might report:

Failed to determine a suitable driver class

Or:

Cannot load driver class: com.mysql.cj.jdbc.Driver

These errors are related, but not identical to the original database type NONE message.

How to confirm

For a Maven project using the current Connector/J artifact, run:

./mvnw dependency:tree -Dincludes=com.mysql:mysql-connector-j

You should find a dependency similar to:

com.mysql:mysql-connector-j:jar:...:runtime

The actual version depends on your project.

For Gradle:

./gradlew dependencies --configuration runtimeClasspath

Search the output for mysql-connector-j.

If the driver isn't listed, check the dependency declaration, dependency exclusions, and build configuration.

How to fix

Add the dependency shown in the quick fix, reload the project, and rebuild.

Older Spring Boot applications may use:

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

That's the older Maven artifact name. Don't replace it blindly without checking the project's Spring Boot version and dependency management.

For current MySQL Connector/J releases, the driver class is:

com.mysql.cj.jdbc.Driver

The older class name:

com.mysql.jdbc.Driver

is deprecated in newer Connector/J versions.

MySQL confirms the current driver name in its Connector/J documentation.

My preference is to let Spring Boot manage the connector version whenever possible rather than manually mixing unrelated library versions.

Cause 3: Spring Boot isn't loading your database profile

This one is easy to miss because the configuration can look perfectly correct.

Imagine your database settings live here:

src/main/resources/application-dev.properties

With:

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/appdb
spring.datasource.username=appuser
spring.datasource.password=your_password

But you launch the application without activating dev.

Spring Boot might never apply those properties.

How to confirm

Check the startup log for a message about active profiles.

You might see:

No active profile set, falling back to default profiles

The exact wording varies across Spring Boot versions.

How to fix

Activate your development profile.

With Maven:

./mvnw spring-boot:run -Dspring-boot.run.profiles=dev

Or set the environment variable on Linux or macOS:

SPRING_PROFILES_ACTIVE=dev ./mvnw spring-boot:run

On Windows PowerShell:

$env:SPRING_PROFILES_ACTIVE = "dev"
.\mvnw.cmd spring-boot:run

You can also set the active profile in the base application.properties:

spring.profiles.active=dev

Use that only when selecting the profile in application configuration makes sense for your deployment.

Don't put spring.profiles.active inside application-dev.properties on modern Spring Boot versions. Profile activation belongs in a non-profile-specific configuration source.

One more gotcha: environment variables, command-line arguments, and external configuration files can override packaged configuration.

A correct setting in your source repository doesn't guarantee that's the value the running application receives.

Cause 4: The JDBC URL or MySQL server address is wrong

Once Spring identifies the JDBC driver, the next step is establishing a network connection.

A typical MySQL JDBC URL looks like:

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/appdb

The jdbc:mysql:// prefix matters.

This is not a valid MySQL JDBC URL:

spring.datasource.url=mysql://127.0.0.1:3306/appdb

The second format is missing jdbc:.

Check that MySQL is reachable

Try connecting directly with the MySQL command-line client:

mysql -h 127.0.0.1 -P 3306 -u appuser -p appdb

Enter your password when prompted.

If it works, run:

SELECT 1;

You should get a result containing 1.

If you receive Access denied, investigate credentials and MySQL account permissions.

If you receive Unknown database, confirm that the named database exists.

If you receive a connection error, check that MySQL is running and listening on the expected interface and port.

For another explanation of MySQL host values, see our guide to the host parameter in mysqli_connect(). That's the PHP interface, not JDBC, but the server address and connection troubleshooting concepts overlap.

Important: A MySQL connection failure normally produces a different underlying exception from database type NONE. Don't spend time resetting passwords until Spring Boot can actually select its JDBC driver.

Cause 5: Spring Boot tries to configure a database your application doesn't use

Sometimes the application isn't supposed to connect to MySQL at all.

For example, you create a Spring Boot web service that only handles HTTP requests, but the project includes:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

Spring Boot sees database-related dependencies and attempts to configure a DataSource.

With no JDBC URL or embedded database available, initialization can fail.

How to confirm

Check pom.xml or build.gradle for dependencies such as:

spring-boot-starter-data-jpa
spring-boot-starter-jdbc

Then check whether your application actually uses JDBC, repositories, JPA entities, or database-backed services.

How to fix

If the dependency was added accidentally, remove it.

If the application genuinely doesn't need a database, you can exclude DataSource auto-configuration:

package com.example.demo;

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

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

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

Adjust the package and application class to match your project.

This prevents Spring Boot from automatically creating a DataSource.

Don't use this as a shortcut in a real MySQL/JPA application. Excluding auto-configuration doesn't repair the connection. It may simply replace the original error with missing DataSource, repository, or entity manager errors.

If you actually want an in-memory database for development or tests, add an appropriate embedded database dependency instead, such as H2:

<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>runtime</scope>
</dependency>

Only do that when an embedded database is intentional. It isn't a substitute for MySQL.

Cause 6: The app works locally but fails after packaging or deployment

A working IDE launch doesn't prove the deployed application has the same configuration.

The deployed process may use another active profile, missing environment variables, or a package without the expected JDBC dependency.

Check the packaged application

First build the application:

./mvnw clean package

For an executable Spring Boot JAR, inspect its contents:

jar tf target/your-app.jar

Replace your-app.jar with the actual output filename.

Search the listing for the MySQL connector under the packaged libraries, typically within BOOT-INF/lib for an executable Spring Boot JAR using that layout.

Also inspect the packaged configuration under BOOT-INF/classes.

If your project builds a different deployment format, inspect that format instead.

A clean package can also reveal resource-copying mistakes.

For example, the source application.properties might contain a database URL while the copied configuration in target/classes is empty or outdated.

A clean rebuild removes stale build output before packaging.

If MySQL is hosted separately from the application, make sure the JDBC URL uses the hostname reachable from the application's runtime environment. Inside Docker, 127.0.0.1 refers to the container itself, not automatically to the host machine.

If nothing worked: capture the real Spring Boot failure

At this point, stop changing random properties and collect the first meaningful exception.

Spring's top-level BeanCreationException often wraps a more specific failure.

The useful message is frequently near the bottom of the stack trace, following Caused by:.

Enable Spring Boot debug output

For Maven:

./mvnw spring-boot:run -Dspring-boot.run.arguments=--debug

For Gradle:

./gradlew bootRun --args='--debug'

Debug mode shows more information about Spring Boot's auto-configuration decisions.

It can help establish why DataSource auto-configuration was selected and which configuration conditions matched.

Debug output doesn't automatically print every effective database property.

Save the startup log

On Linux or macOS:

./mvnw spring-boot:run > startup.log 2>&1

On Windows PowerShell:

.\mvnw.cmd spring-boot:run *> startup.log

Open startup.log and search for:

Caused by:
DataSourceAutoConfiguration
DataSourceProperties
Failed to determine a suitable driver class
Cannot load driver class
Access denied
Communications link failure

Interpret the first relevant root cause rather than treating every nested exception as a separate failure.

A useful troubleshooting report includes the Spring Boot version, active profile, sanitized JDBC URL, relevant dependency tree, and the first underlying exception.

Remove passwords, tokens, and other secrets before sharing logs or configuration.

For comparison, problems such as Laravel migrations and MySQL seeding failures happen at a different stage. If your Spring application never created its DataSource, investigating SQL inserts or table relationships is premature.

FAQ

Why does Spring Boot say database type NONE when I'm using MySQL?

NONE doesn't refer to a MySQL storage engine or database type. It's part of the older Spring Boot error wording used when an embedded database can't be identified during DataSource initialization.

Check that Spring receives a valid spring.datasource.url and that the required MySQL driver is available.

Is spring.datasource.driver-class-name required for MySQL?

Usually not. Spring Boot can identify the driver from a correctly configured jdbc:mysql:// URL when Connector/J is on the runtime classpath.

You can explicitly set spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver while troubleshooting. The setting won't help if the driver library itself is missing.

Can I fix this by adding H2 instead of MySQL Connector/J?

Only if you intend to use H2 as an embedded database. Adding H2 may allow a separate development or test application to start, but it doesn't configure a connection to your MySQL server.

For a MySQL-backed application, use the MySQL JDBC driver and the correct connection properties.

Why does the application work in the IDE but fail with java -jar?

The IDE and packaged application might not load the same profiles, environment variables, dependencies, or configuration files.

Compare the effective startup settings and inspect the packaged JAR. Don't assume the database driver is included simply because the project compiles successfully.

What's the difference between "Cannot determine embedded database driver class" and "Failed to determine a suitable driver class"?

Both errors concern Spring Boot's ability to configure a JDBC DataSource. The first is associated with older Spring Boot error messages, while newer versions commonly report the second.

The same diagnostic approach applies: check the JDBC URL, available driver, loaded configuration, and active profile before investigating the MySQL server.

If you're still getting beancreationexception: cannot determine embedded database driver class for database type none, gather the sanitized startup log and dependency tree, then use HeadsNTail services if you need hands-on help identifying the remaining configuration issue.

Free tools for MySQL work

All free tools →

More MySQL articles