DataSource url not specified ☕ Java

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Spring Boot found JDBC/JPA on the classpath but no database URL.

Seen on: Java

Meaning

Adding spring-boot-starter-data-jpa triggers DataSource auto-configuration. Without spring.datasource.url (or an embedded DB like H2), startup fails. Profile-specific properties not loading is another cause.

Common causes

  • spring.datasource.url missing
  • Active profile not set, so application-prod.properties not loaded
  • Environment variables not provided
  • JPA added but no database intended

⚡ Quick fix

  1. Set spring.datasource.url/username/password
  2. Activate the right profile (SPRING_PROFILES_ACTIVE)
  3. Add H2 for local dev, or exclude DataSourceAutoConfiguration if no DB is needed

Detailed fix by platform

Java

  1. spring.datasource.url=jdbc:postgresql://localhost:5432/app

How to diagnose

  1. Properties — Which file sets the URL?
  2. Profile — Which profile is active?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.