***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
DataSourceAutoConfiguration is active because JDBC support is on the classpath. It looked for spring.datasource.url, found nothing, found no embedded database (H2, HSQL, Derby) to fall back on, and stopped startup.
TLDR
- Datasource settings exist but weren’t read (wrong file location, inactive profile, misplaced YAML key): fix where the property comes from, or activate the profile.
- The app has no database: remove the JDBC/JPA starter, or exclude
DataSourceAutoConfiguration. - You want an in-memory database for tests: add H2 with
testscope. - First check:
grep -r "spring.datasource" src/main/resources, then confirm the file is inside the built jar.
When the same failure is logged as a stack trace instead of the banner, it looks like this:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at com.example.shop.ShopApplication.main(ShopApplication.java:10)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:171)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:531)
... 18 common frames omitted
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:238)
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:186)
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:97)
... 20 common frames omitted
The last Caused by is the root. The frames above it are Spring building whichever bean needed a DataSource first (entityManagerFactory here). Pasting the full trace into Debugly’s formatter separates the chained causes and the repeated framework frames, so the failing bean and the root cause are easy to see together. Class names and line numbers vary by Spring Boot version.
The properties file exists but is not being read
This is the usual case when you believe the datasource is configured.
The file is in the wrong place. Boot reads application.properties or application.yml from the classpath root, which means src/main/resources. A file in src/main/, the repository root of a multi-module build, or a sibling module is ignored.
The YAML key is at the wrong level. Indentation decides the key:
# Parsed as "datasource.url", not "spring.datasource.url"
datasource:
url: jdbc:postgresql://localhost:5432/shop
# Fix:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/shop
username: shop
password: secret
The key for a Boot-managed datasource is url. jdbc-url is what you bind when you build a HikariDataSource yourself with @ConfigurationProperties.
The file is missing from the build output. Check the jar, where Spring Boot fat jars keep it under BOOT-INF/classes/:
unzip -l target/shop-0.0.1.jar | grep application
Resource filtering or an <excludes> entry in the build config can drop it.
The settings are in a profile that is not active
The banner’s no profiles are currently active line points here. Settings in application-dev.yml, or in a document with spring.config.activate.on-profile: dev, load only when that profile is on:
java -jar target/shop-0.0.1.jar --spring.profiles.active=dev
SPRING_PROFILES_ACTIVE=dev java -jar target/shop-0.0.1.jar
In tests, @ActiveProfiles("test") does the same. If the profile is set and still ignored, see Spring profiles not loading.
A starter brought in JDBC and the app has no database
For a service that has no database, something on the classpath still pulled in spring-jdbc: spring-boot-starter-jdbc, spring-boot-starter-data-jpa, spring-boot-starter-batch, or a library that depends on one. Find it:
mvn dependency:tree | grep -E "jdbc|jpa|batch"
./gradlew dependencies --configuration runtimeClasspath | grep -E "jdbc|jpa|batch"
Remove the dependency if you don’t need it. If you need the library but not a datasource, exclude the auto-configuration:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class ShopApplication {
public static void main(String[] args) {
SpringApplication.run(ShopApplication.class, args);
}
}
Or in properties:
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
With JPA on the classpath, also exclude HibernateJpaAutoConfiguration, otherwise startup fails next on the missing DataSource bean.
Spring Batch needs a datasource for its job repository, so excluding the auto-configuration only moves the failure. Give it an embedded database or a real one.
An embedded database is what you want for tests
The Action text suggests H2, HSQL or Derby. With one on the classpath and no spring.datasource.url, Boot creates an in-memory database:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
Keep it in test scope so production still fails fast when the URL is missing, instead of quietly running on an in-memory database.
The URL comes from an environment variable with the wrong name
Relaxed binding maps SPRING_DATASOURCE_URL to spring.datasource.url. DATASOURCE_URL or DB_URL are not mapped unless your properties file references them, for example spring.datasource.url=${DB_URL}. If that placeholder is unresolved you get a Could not resolve placeholder error instead of this one, so seeing this error with an env-based setup usually means the variable name doesn’t match. In a container, check what the process sees:
docker exec shop env | grep -i datasource
For reading other startup failures where a bean can’t be built, BeanCreationException troubleshooting covers the Caused by chain.