Create spring-boot-h2console module
This commit is contained in:
parent
68c1d45ea8
commit
d2a1dcbc8e
|
@ -63,6 +63,7 @@ include "spring-boot-project:spring-boot-flyway"
|
||||||
include "spring-boot-project:spring-boot-freemarker"
|
include "spring-boot-project:spring-boot-freemarker"
|
||||||
include "spring-boot-project:spring-boot-groovy-templates"
|
include "spring-boot-project:spring-boot-groovy-templates"
|
||||||
include "spring-boot-project:spring-boot-gson"
|
include "spring-boot-project:spring-boot-gson"
|
||||||
|
include "spring-boot-project:spring-boot-h2console"
|
||||||
include "spring-boot-project:spring-boot-hazelcast"
|
include "spring-boot-project:spring-boot-hazelcast"
|
||||||
include "spring-boot-project:spring-boot-integration"
|
include "spring-boot-project:spring-boot-integration"
|
||||||
include "spring-boot-project:spring-boot-jackson"
|
include "spring-boot-project:spring-boot-jackson"
|
||||||
|
|
|
@ -48,6 +48,7 @@ dependencies {
|
||||||
optional(project(":spring-boot-project:spring-boot-data-jpa"))
|
optional(project(":spring-boot-project:spring-boot-data-jpa"))
|
||||||
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
|
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
|
||||||
optional(project(":spring-boot-project:spring-boot-flyway"))
|
optional(project(":spring-boot-project:spring-boot-flyway"))
|
||||||
|
optional(project(":spring-boot-project:spring-boot-h2console"))
|
||||||
optional(project(":spring-boot-project:spring-boot-hazelcast"))
|
optional(project(":spring-boot-project:spring-boot-hazelcast"))
|
||||||
optional(project(":spring-boot-project:spring-boot-jackson"))
|
optional(project(":spring-boot-project:spring-boot-jackson"))
|
||||||
optional(project(":spring-boot-project:spring-boot-jdbc"))
|
optional(project(":spring-boot-project:spring-boot-jdbc"))
|
||||||
|
@ -70,7 +71,6 @@ dependencies {
|
||||||
optional("com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations")
|
optional("com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations")
|
||||||
optional("com.fasterxml.jackson.module:jackson-module-parameter-names")
|
optional("com.fasterxml.jackson.module:jackson-module-parameter-names")
|
||||||
optional("com.hazelcast:hazelcast-spring")
|
optional("com.hazelcast:hazelcast-spring")
|
||||||
optional("com.h2database:h2")
|
|
||||||
optional("com.nimbusds:oauth2-oidc-sdk")
|
optional("com.nimbusds:oauth2-oidc-sdk")
|
||||||
optional("com.oracle.database.jdbc:ojdbc11")
|
optional("com.oracle.database.jdbc:ojdbc11")
|
||||||
optional("com.oracle.database.jdbc:ucp11")
|
optional("com.oracle.database.jdbc:ucp11")
|
||||||
|
|
|
@ -20,12 +20,14 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.h2.H2ConsoleProperties;
|
|
||||||
import org.springframework.boot.autoconfigure.security.StaticResourceLocation;
|
import org.springframework.boot.autoconfigure.security.StaticResourceLocation;
|
||||||
|
import org.springframework.boot.h2console.autoconfigure.H2ConsoleProperties;
|
||||||
import org.springframework.boot.security.servlet.ApplicationContextRequestMatcher;
|
import org.springframework.boot.security.servlet.ApplicationContextRequestMatcher;
|
||||||
import org.springframework.boot.web.context.WebServerApplicationContext;
|
import org.springframework.boot.web.context.WebServerApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
|
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
|
||||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,12 +65,12 @@ public final class PathRequest {
|
||||||
/**
|
/**
|
||||||
* The request matcher used to match against h2 console path.
|
* The request matcher used to match against h2 console path.
|
||||||
*/
|
*/
|
||||||
public static final class H2ConsoleRequestMatcher extends ApplicationContextRequestMatcher<H2ConsoleProperties> {
|
public static final class H2ConsoleRequestMatcher extends ApplicationContextRequestMatcher<ApplicationContext> {
|
||||||
|
|
||||||
private volatile RequestMatcher delegate;
|
private volatile RequestMatcher delegate;
|
||||||
|
|
||||||
private H2ConsoleRequestMatcher() {
|
private H2ConsoleRequestMatcher() {
|
||||||
super(H2ConsoleProperties.class);
|
super(ApplicationContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,13 +79,14 @@ public final class PathRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialized(Supplier<H2ConsoleProperties> h2ConsoleProperties) {
|
protected void initialized(Supplier<ApplicationContext> context) {
|
||||||
this.delegate = PathPatternRequestMatcher.withDefaults()
|
String path = context.get().getBean(H2ConsoleProperties.class).getPath();
|
||||||
.matcher(h2ConsoleProperties.get().getPath() + "/**");
|
Assert.hasText(path, "'path' in H2ConsoleProperties must not be empty");
|
||||||
|
this.delegate = PathPatternRequestMatcher.withDefaults().matcher(path + "/**");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean matches(HttpServletRequest request, Supplier<H2ConsoleProperties> context) {
|
protected boolean matches(HttpServletRequest request, Supplier<ApplicationContext> context) {
|
||||||
return this.delegate.matches(request);
|
return this.delegate.matches(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ org.springframework.boot.autoconfigure.graphql.rsocket.RSocketGraphQlClientAutoC
|
||||||
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebFluxSecurityAutoConfiguration
|
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebFluxSecurityAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebMvcSecurityAutoConfiguration
|
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebMvcSecurityAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration
|
org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration
|
|
||||||
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration
|
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration
|
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration
|
org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration
|
||||||
|
|
|
@ -20,8 +20,8 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.assertj.core.api.AssertDelegateTarget;
|
import org.assertj.core.api.AssertDelegateTarget;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.h2.H2ConsoleProperties;
|
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
|
import org.springframework.boot.h2console.autoconfigure.H2ConsoleProperties;
|
||||||
import org.springframework.mock.web.MockHttpServletRequest;
|
import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
import org.springframework.mock.web.MockServletContext;
|
import org.springframework.mock.web.MockServletContext;
|
||||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||||
|
|
|
@ -2034,6 +2034,7 @@ bom {
|
||||||
"spring-boot-freemarker",
|
"spring-boot-freemarker",
|
||||||
"spring-boot-groovy-templates",
|
"spring-boot-groovy-templates",
|
||||||
"spring-boot-gson",
|
"spring-boot-gson",
|
||||||
|
"spring-boot-h2console",
|
||||||
"spring-boot-hazelcast",
|
"spring-boot-hazelcast",
|
||||||
"spring-boot-integration",
|
"spring-boot-integration",
|
||||||
"spring-boot-jackson",
|
"spring-boot-jackson",
|
||||||
|
|
|
@ -69,6 +69,7 @@ dependencies {
|
||||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "autoConfigurationMetadata"))
|
autoConfiguration(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "autoConfigurationMetadata"))
|
||||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "autoConfigurationMetadata"))
|
autoConfiguration(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "autoConfigurationMetadata"))
|
||||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-gson", configuration: "autoConfigurationMetadata"))
|
autoConfiguration(project(path: ":spring-boot-project:spring-boot-gson", configuration: "autoConfigurationMetadata"))
|
||||||
|
autoConfiguration(project(path: ":spring-boot-project:spring-boot-h2console", configuration: "autoConfigurationMetadata"))
|
||||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "autoConfigurationMetadata"))
|
autoConfiguration(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "autoConfigurationMetadata"))
|
||||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-integration", configuration: "autoConfigurationMetadata"))
|
autoConfiguration(project(path: ":spring-boot-project:spring-boot-integration", configuration: "autoConfigurationMetadata"))
|
||||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "autoConfigurationMetadata"))
|
autoConfiguration(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "autoConfigurationMetadata"))
|
||||||
|
@ -116,6 +117,7 @@ dependencies {
|
||||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "configurationPropertiesMetadata"))
|
configurationProperties(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "configurationPropertiesMetadata"))
|
||||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "configurationPropertiesMetadata"))
|
configurationProperties(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "configurationPropertiesMetadata"))
|
||||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-gson", configuration: "configurationPropertiesMetadata"))
|
configurationProperties(project(path: ":spring-boot-project:spring-boot-gson", configuration: "configurationPropertiesMetadata"))
|
||||||
|
configurationProperties(project(path: ":spring-boot-project:spring-boot-h2console", configuration: "configurationPropertiesMetadata"))
|
||||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "configurationPropertiesMetadata"))
|
configurationProperties(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "configurationPropertiesMetadata"))
|
||||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-integration", configuration: "configurationPropertiesMetadata"))
|
configurationProperties(project(path: ":spring-boot-project:spring-boot-integration", configuration: "configurationPropertiesMetadata"))
|
||||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "configurationPropertiesMetadata"))
|
configurationProperties(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "configurationPropertiesMetadata"))
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
plugins {
|
||||||
|
id "java-library"
|
||||||
|
id "org.springframework.boot.auto-configuration"
|
||||||
|
id "org.springframework.boot.configuration-properties"
|
||||||
|
id "org.springframework.boot.deployed"
|
||||||
|
id "org.springframework.boot.optional-dependencies"
|
||||||
|
}
|
||||||
|
|
||||||
|
description = "Spring Boot H2"
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(project(":spring-boot-project:spring-boot"))
|
||||||
|
api("jakarta.servlet:jakarta.servlet-api")
|
||||||
|
api("com.h2database:h2")
|
||||||
|
|
||||||
|
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
|
||||||
|
|
||||||
|
testImplementation(project(":spring-boot-project:spring-boot-test"))
|
||||||
|
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
|
||||||
|
testImplementation(project(":spring-boot-project:spring-boot-jdbc"))
|
||||||
|
testImplementation(project(":spring-boot-project:spring-boot-tomcat"))
|
||||||
|
testImplementation("org.springframework:spring-web")
|
||||||
|
|
||||||
|
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||||
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.h2;
|
package org.springframework.boot.h2console.autoconfigure;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -33,9 +33,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProp
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||||
import org.springframework.boot.autoconfigure.h2.H2ConsoleProperties.Settings;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
|
import org.springframework.boot.h2console.autoconfigure.H2ConsoleProperties.Settings;
|
||||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.core.log.LogMessage;
|
import org.springframework.core.log.LogMessage;
|
||||||
|
@ -47,9 +46,9 @@ import org.springframework.core.log.LogMessage;
|
||||||
* @author Marten Deinum
|
* @author Marten Deinum
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 1.3.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration(after = DataSourceAutoConfiguration.class)
|
@AutoConfiguration
|
||||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||||
@ConditionalOnClass(JakartaWebServlet.class)
|
@ConditionalOnClass(JakartaWebServlet.class)
|
||||||
@ConditionalOnBooleanProperty("spring.h2.console.enabled")
|
@ConditionalOnBooleanProperty("spring.h2.console.enabled")
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.h2;
|
package org.springframework.boot.h2console.autoconfigure;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
@ -25,7 +25,7 @@ import org.springframework.util.Assert;
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Marten Deinum
|
* @author Marten Deinum
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.3.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties("spring.h2.console")
|
@ConfigurationProperties("spring.h2.console")
|
||||||
public class H2ConsoleProperties {
|
public class H2ConsoleProperties {
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,4 +17,4 @@
|
||||||
/**
|
/**
|
||||||
* Auto-configuration for H2's Console.
|
* Auto-configuration for H2's Console.
|
||||||
*/
|
*/
|
||||||
package org.springframework.boot.autoconfigure.h2;
|
package org.springframework.boot.h2console.autoconfigure;
|
|
@ -0,0 +1 @@
|
||||||
|
org.springframework.boot.h2console.autoconfigure.H2ConsoleAutoConfiguration
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.h2;
|
package org.springframework.boot.h2console.autoconfigure;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.h2;
|
package org.springframework.boot.h2console.autoconfigure;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
Loading…
Reference in New Issue