Skip to content

Commit 1c3a918

Browse files
committed
Remove reference to spring.datasource.jmx-enabled
This commits moves the single use of that property to the already existing Tomcat-specific one. Closes spring-projectsgh-16673
1 parent 22ae160 commit 1c3a918

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

Diff for: spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void validateMBeans() {
7575
}
7676

7777
@Configuration(proxyBeanMethods = false)
78-
@ConditionalOnProperty(prefix = "spring.datasource", name = "jmx-enabled")
78+
@ConditionalOnProperty(prefix = "spring.datasource.tomcat", name = "jmx-enabled")
7979
@ConditionalOnClass(DataSourceProxy.class)
8080
@ConditionalOnSingleCandidate(DataSource.class)
8181
static class TomcatDataSourceJmxConfiguration {

Diff for: spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,6 @@
298298
"description": "Whether to enable the PersistenceExceptionTranslationPostProcessor.",
299299
"defaultValue": true
300300
},
301-
{
302-
"name": "spring.datasource.jmx-enabled",
303-
"type": "java.lang.Boolean",
304-
"description": "Whether to enable JMX support (if provided by the underlying pool).",
305-
"defaultValue": false
306-
},
307301
{
308302
"name": "spring.datasource.initialization-mode",
309303
"defaultValue": "embedded"
@@ -1572,6 +1566,16 @@
15721566
"level": "error"
15731567
}
15741568
},
1569+
{
1570+
"name": "spring.datasource.jmx-enabled",
1571+
"type": "java.lang.Boolean",
1572+
"description": "Whether to enable JMX support (if provided by the underlying pool).",
1573+
"defaultValue": false,
1574+
"deprecation": {
1575+
"level": "error",
1576+
"replacement": "spring.datasource.tomcat.jmx-enabled"
1577+
}
1578+
},
15751579
{
15761580
"name": "spring.datasource.initialize",
15771581
"defaultValue": true,

Diff for: spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfigurationTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void tomcatDoesNotExposeMBeanPoolByDefault() {
156156
public void tomcatAutoConfiguredCanExposeMBeanPool() {
157157
this.contextRunner.withPropertyValues(
158158
"spring.datasource.type=" + DataSource.class.getName(),
159-
"spring.datasource.jmx-enabled=true").run((context) -> {
159+
"spring.datasource.tomcat.jmx-enabled=true").run((context) -> {
160160
assertThat(context).hasBean("dataSourceMBean");
161161
assertThat(context).hasSingleBean(ConnectionPool.class);
162162
assertThat(context.getBean(DataSourceProxy.class).createPool()
@@ -170,7 +170,7 @@ public void tomcatProxiedCanExposeMBeanPool() {
170170
this.contextRunner.withUserConfiguration(DataSourceProxyConfiguration.class)
171171
.withPropertyValues(
172172
"spring.datasource.type=" + DataSource.class.getName(),
173-
"spring.datasource.jmx-enabled=true")
173+
"spring.datasource.tomcat.jmx-enabled=true")
174174
.run((context) -> {
175175
assertThat(context).hasBean("dataSourceMBean");
176176
assertThat(context).getBean("dataSourceMBean")
@@ -183,7 +183,7 @@ public void tomcatDelegateCanExposeMBeanPool() {
183183
this.contextRunner.withUserConfiguration(DataSourceDelegateConfiguration.class)
184184
.withPropertyValues(
185185
"spring.datasource.type=" + DataSource.class.getName(),
186-
"spring.datasource.jmx-enabled=true")
186+
"spring.datasource.tomcat.jmx-enabled=true")
187187
.run((context) -> {
188188
assertThat(context).hasBean("dataSourceMBean");
189189
assertThat(context).getBean("dataSourceMBean")

Diff for: spring-boot-samples/spring-boot-sample-data-jpa/src/test/java/sample/data/jpa/SampleDataJpaApplicationTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
* @author Dave Syer
4343
*/
4444
// Enable JMX so we can test the MBeans (you can't do this in a properties file)
45-
@SpringBootTest(
46-
properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
45+
@SpringBootTest(properties = "spring.jmx.enabled:true")
4746
@ActiveProfiles("scratch")
4847
// Separate profile for web tests to avoid clashing databases
4948
class SampleDataJpaApplicationTests {

0 commit comments

Comments
 (0)