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

**Code:** `DataSource url not specified` · **Category:** Java · **Seen on:** Java

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/java/spring-failed-to-configure-datasource)
