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
pull/16850/head
Stephane Nicoll 6 years ago
parent 22ae160faa
commit 1c3a91883d

@ -75,7 +75,7 @@ class DataSourceJmxConfiguration {
} }
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "spring.datasource", name = "jmx-enabled") @ConditionalOnProperty(prefix = "spring.datasource.tomcat", name = "jmx-enabled")
@ConditionalOnClass(DataSourceProxy.class) @ConditionalOnClass(DataSourceProxy.class)
@ConditionalOnSingleCandidate(DataSource.class) @ConditionalOnSingleCandidate(DataSource.class)
static class TomcatDataSourceJmxConfiguration { static class TomcatDataSourceJmxConfiguration {

@ -298,12 +298,6 @@
"description": "Whether to enable the PersistenceExceptionTranslationPostProcessor.", "description": "Whether to enable the PersistenceExceptionTranslationPostProcessor.",
"defaultValue": true "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", "name": "spring.datasource.initialization-mode",
"defaultValue": "embedded" "defaultValue": "embedded"
@ -1572,6 +1566,16 @@
"level": "error" "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", "name": "spring.datasource.initialize",
"defaultValue": true, "defaultValue": true,

@ -156,7 +156,7 @@ public class DataSourceJmxConfigurationTests {
public void tomcatAutoConfiguredCanExposeMBeanPool() { public void tomcatAutoConfiguredCanExposeMBeanPool() {
this.contextRunner.withPropertyValues( this.contextRunner.withPropertyValues(
"spring.datasource.type=" + DataSource.class.getName(), "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).hasBean("dataSourceMBean");
assertThat(context).hasSingleBean(ConnectionPool.class); assertThat(context).hasSingleBean(ConnectionPool.class);
assertThat(context.getBean(DataSourceProxy.class).createPool() assertThat(context.getBean(DataSourceProxy.class).createPool()
@ -170,7 +170,7 @@ public class DataSourceJmxConfigurationTests {
this.contextRunner.withUserConfiguration(DataSourceProxyConfiguration.class) this.contextRunner.withUserConfiguration(DataSourceProxyConfiguration.class)
.withPropertyValues( .withPropertyValues(
"spring.datasource.type=" + DataSource.class.getName(), "spring.datasource.type=" + DataSource.class.getName(),
"spring.datasource.jmx-enabled=true") "spring.datasource.tomcat.jmx-enabled=true")
.run((context) -> { .run((context) -> {
assertThat(context).hasBean("dataSourceMBean"); assertThat(context).hasBean("dataSourceMBean");
assertThat(context).getBean("dataSourceMBean") assertThat(context).getBean("dataSourceMBean")
@ -183,7 +183,7 @@ public class DataSourceJmxConfigurationTests {
this.contextRunner.withUserConfiguration(DataSourceDelegateConfiguration.class) this.contextRunner.withUserConfiguration(DataSourceDelegateConfiguration.class)
.withPropertyValues( .withPropertyValues(
"spring.datasource.type=" + DataSource.class.getName(), "spring.datasource.type=" + DataSource.class.getName(),
"spring.datasource.jmx-enabled=true") "spring.datasource.tomcat.jmx-enabled=true")
.run((context) -> { .run((context) -> {
assertThat(context).hasBean("dataSourceMBean"); assertThat(context).hasBean("dataSourceMBean");
assertThat(context).getBean("dataSourceMBean") assertThat(context).getBean("dataSourceMBean")

@ -42,8 +42,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
* @author Dave Syer * @author Dave Syer
*/ */
// Enable JMX so we can test the MBeans (you can't do this in a properties file) // Enable JMX so we can test the MBeans (you can't do this in a properties file)
@SpringBootTest( @SpringBootTest(properties = "spring.jmx.enabled:true")
properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
@ActiveProfiles("scratch") @ActiveProfiles("scratch")
// Separate profile for web tests to avoid clashing databases // Separate profile for web tests to avoid clashing databases
class SampleDataJpaApplicationTests { class SampleDataJpaApplicationTests {

Loading…
Cancel
Save