Skip to content

Commit 0b09f2b

Browse files
committed
Add spring-boot-h2console module in addition to the H2 database dependency
See gh-2008
1 parent 76fe2ca commit 0b09f2b

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

start-site/src/main/java/io/spring/start/site/extension/dependency/h2/H2ProjectGenerationConfiguration.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package io.spring.start.site.extension.dependency.h2;
1818

1919
import io.spring.initializr.generator.buildsystem.Build;
20-
import io.spring.initializr.generator.buildsystem.Dependency;
2120
import io.spring.initializr.generator.buildsystem.DependencyScope;
2221
import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion;
2322
import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency;
@@ -36,12 +35,10 @@
3635
class H2ProjectGenerationConfiguration {
3736

3837
@Bean
39-
@ConditionalOnPlatformVersion("[3.4.0,4.0.0)")
40-
BuildCustomizer<Build> switchH2ScopeToRuntimeBuildCustomizer() {
41-
return (build) -> {
42-
Dependency h2 = build.dependencies().get("h2");
43-
build.dependencies().add("h2", Dependency.from(h2).scope(DependencyScope.RUNTIME));
44-
};
38+
@ConditionalOnPlatformVersion("4.0.0")
39+
BuildCustomizer<Build> addH2ConsoleModuleBuildCustomizer() {
40+
return (build) -> build.dependencies()
41+
.add("spring-boot-h2console", "org.springframework.boot", "spring-boot-h2console", DependencyScope.COMPILE);
4542
}
4643

4744
}

start-site/src/main/resources/application.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -716,12 +716,9 @@ initializr:
716716
- name: H2 Database
717717
id: h2
718718
description: Provides a fast in-memory database that supports JDBC API and R2DBC access, with a small (2mb) footprint. Supports embedded and server modes as well as a browser based console application.
719-
mappings:
720-
- compatibility-range: "[3.4.0,4.0.0)"
721-
groupId: com.h2database
722-
artifactId: h2
723-
groupId: org.springframework.boot
724-
artifactId: spring-boot-h2console
719+
groupId: com.h2database
720+
artifactId: h2
721+
scope: runtime
725722
starter: false
726723
- name: HyperSQL Database
727724
id: hsql

start-site/src/test/java/io/spring/start/site/extension/dependency/h2/H2ProjectGenerationConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class H2ProjectGenerationConfigurationTests extends AbstractExtensionTests {
3535

3636
@ParameterizedTest
3737
@EnumSource(value = SupportedBootVersion.class, names = { "V3_4", "V3_5" })
38-
void shouldAddH2inRuntimeScopeForBootBelow4(SupportedBootVersion bootVersion) {
38+
void shouldNotAddH2ConsoleModule(SupportedBootVersion bootVersion) {
3939
ProjectRequest request = createProjectRequest(bootVersion, "h2");
40-
assertThat(mavenPom(request)).hasDependency("com.h2database", "h2", null, Dependency.SCOPE_RUNTIME);
40+
assertThat(mavenPom(request)).doesNotHaveDependency("org.springframework.boot", "spring-boot-h2console");
4141
}
4242

4343
@Test

0 commit comments

Comments
 (0)