From 1c3a91883d174bd9ecbe54bb7590ec210d44dc13 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 13 May 2019 17:11:03 +0200 Subject: [PATCH] Remove reference to spring.datasource.jmx-enabled This commits moves the single use of that property to the already existing Tomcat-specific one. Closes gh-16673 --- .../jdbc/DataSourceJmxConfiguration.java | 2 +- ...additional-spring-configuration-metadata.json | 16 ++++++++++------ .../jdbc/DataSourceJmxConfigurationTests.java | 6 +++--- .../data/jpa/SampleDataJpaApplicationTests.java | 3 +-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfiguration.java index d409b98338..f9129b7d84 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfiguration.java @@ -75,7 +75,7 @@ class DataSourceJmxConfiguration { } @Configuration(proxyBeanMethods = false) - @ConditionalOnProperty(prefix = "spring.datasource", name = "jmx-enabled") + @ConditionalOnProperty(prefix = "spring.datasource.tomcat", name = "jmx-enabled") @ConditionalOnClass(DataSourceProxy.class) @ConditionalOnSingleCandidate(DataSource.class) static class TomcatDataSourceJmxConfiguration { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 2af2102fe1..4f5d6cfc14 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -298,12 +298,6 @@ "description": "Whether to enable the PersistenceExceptionTranslationPostProcessor.", "defaultValue": true }, - { - "name": "spring.datasource.jmx-enabled", - "type": "java.lang.Boolean", - "description": "Whether to enable JMX support (if provided by the underlying pool).", - "defaultValue": false - }, { "name": "spring.datasource.initialization-mode", "defaultValue": "embedded" @@ -1572,6 +1566,16 @@ "level": "error" } }, + { + "name": "spring.datasource.jmx-enabled", + "type": "java.lang.Boolean", + "description": "Whether to enable JMX support (if provided by the underlying pool).", + "defaultValue": false, + "deprecation": { + "level": "error", + "replacement": "spring.datasource.tomcat.jmx-enabled" + } + }, { "name": "spring.datasource.initialize", "defaultValue": true, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfigurationTests.java index d6f266baa8..3734d773a4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfigurationTests.java @@ -156,7 +156,7 @@ public class DataSourceJmxConfigurationTests { public void tomcatAutoConfiguredCanExposeMBeanPool() { this.contextRunner.withPropertyValues( "spring.datasource.type=" + DataSource.class.getName(), - "spring.datasource.jmx-enabled=true").run((context) -> { + "spring.datasource.tomcat.jmx-enabled=true").run((context) -> { assertThat(context).hasBean("dataSourceMBean"); assertThat(context).hasSingleBean(ConnectionPool.class); assertThat(context.getBean(DataSourceProxy.class).createPool() @@ -170,7 +170,7 @@ public class DataSourceJmxConfigurationTests { this.contextRunner.withUserConfiguration(DataSourceProxyConfiguration.class) .withPropertyValues( "spring.datasource.type=" + DataSource.class.getName(), - "spring.datasource.jmx-enabled=true") + "spring.datasource.tomcat.jmx-enabled=true") .run((context) -> { assertThat(context).hasBean("dataSourceMBean"); assertThat(context).getBean("dataSourceMBean") @@ -183,7 +183,7 @@ public class DataSourceJmxConfigurationTests { this.contextRunner.withUserConfiguration(DataSourceDelegateConfiguration.class) .withPropertyValues( "spring.datasource.type=" + DataSource.class.getName(), - "spring.datasource.jmx-enabled=true") + "spring.datasource.tomcat.jmx-enabled=true") .run((context) -> { assertThat(context).hasBean("dataSourceMBean"); assertThat(context).getBean("dataSourceMBean") diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/SampleDataJpaApplicationTests.java b/spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/SampleDataJpaApplicationTests.java index fe116ceeaf..a1c96cb105 100644 --- a/spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/SampleDataJpaApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/SampleDataJpaApplicationTests.java @@ -42,8 +42,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * @author Dave Syer */ // Enable JMX so we can test the MBeans (you can't do this in a properties file) -@SpringBootTest( - properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" }) +@SpringBootTest(properties = "spring.jmx.enabled:true") @ActiveProfiles("scratch") // Separate profile for web tests to avoid clashing databases class SampleDataJpaApplicationTests {