Skip to content

Add H2 Configuration in Start.spring.io dependencies section #2008

@salmansheri

Description

@salmansheri

When generating a project with Spring Boot 4.0.0 and selecting the H2 Database dependency, the application fails to auto-configure the H2 embedded database and Console.

With the modularization changes in Spring Boot 4.0 (splitting spring-boot-autoconfigure), the core auto-configuration logic for H2 seems to no longer be included by default when only the H2 driver dependency is present. Users are required to manually configure the DataSource or add missing configuration modules, which breaks the "out-of-the-box" experience found in Spring Boot 3.x.

When the H2 Database dependency (com.h2database:h2) is selected for a Spring Boot 4.0+ project, Spring Initializr should automatically include the corresponding auto-configuration module (e.g., org.springframework.boot:spring-boot-h2console or the relevant spring-boot-autoconfigure-* module) to ensure the database and console are initialized correctly.

Currently, I have to manually add the necessary configuration beans or explicitly include the split auto-configuration modules in pom.xml to get the H2 Console working.

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-h2console</artifactId>
  <version>4.0.0</version>
</dependency>

Add this to dependency section in start.spring.io please

Additional context

Spring Boot Version: 4.0.0

Build Tool: Maven/Gradle

Observed Behavior: H2 Driver is present, the /h2-console endpoint is not registered.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions