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 {