Default spring.datasource.jmx-enabled to false

Change the default value of spring.datasource.jmx-enabled to false
to prevent InstanceAlreadyExistsException problems when using the
Spring Test Framework.

Fixes gh-1590
This commit is contained in:
Phillip Webb 2014-11-06 20:55:04 -08:00
parent d040bb72d3
commit 96a031cf20
6 changed files with 8 additions and 4 deletions

View File

@ -145,7 +145,7 @@ public class DataSourceAutoConfiguration {
}
@Configuration
@ConditionalOnProperty(prefix = "spring.datasource", name = "jmx-enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(prefix = "spring.datasource", name = "jmx-enabled")
@ConditionalOnClass(name = "org.apache.tomcat.jdbc.pool.DataSourceProxy")
@Conditional(DataSourceAutoConfiguration.DataSourceAvailableCondition.class)
@ConditionalOnMissingBean(name = "dataSourceMBean")

View File

@ -27,7 +27,7 @@
"name": "spring.datasource.jmx-enabled",
"dataType": "java.lang.Boolean",
"description": "Enables JMX support (if provided by the underlying pool).",
"defaultValue": true
"defaultValue": false
},
{
"name": "spring.data.elasticsearch.repositories.enabled",

View File

@ -32,6 +32,7 @@ import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.context.annotation.Import;
import org.springframework.util.ReflectionUtils;
@ -133,6 +134,7 @@ public class TomcatDataSourceConfigurationTests {
@Configuration
@Import(DataSourceAutoConfiguration.class)
@EnableMBeanExport
protected static class TomcatDataSourceConfiguration {
@Autowired

View File

@ -203,7 +203,7 @@ content into your application; rather pick only the properties that you need.
spring.datasource.time-between-eviction-runs-millis=
spring.datasource.min-evictable-idle-time-millis=
spring.datasource.max-wait=
spring.datasource.jmx-enabled=true # Export JMX MBeans (if supported)
spring.datasource.jmx-enabled=false # Export JMX MBeans (if supported)
# DATASOURCE ({sc-spring-boot-autoconfigure}/dao/PersistenceExceptionTranslationAutoConfiguration.{sc-ext}[PersistenceExceptionTranslationAutoConfiguration]
spring.dao.exceptiontranslation.enabled=true

View File

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

View File

@ -6,6 +6,7 @@ Base logback configuration provided for compatibility with Spring Boot 1.1
<included>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">