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:
@@ -145,7 +145,7 @@ public class DataSourceAutoConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@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")
|
@ConditionalOnClass(name = "org.apache.tomcat.jdbc.pool.DataSourceProxy")
|
||||||
@Conditional(DataSourceAutoConfiguration.DataSourceAvailableCondition.class)
|
@Conditional(DataSourceAutoConfiguration.DataSourceAvailableCondition.class)
|
||||||
@ConditionalOnMissingBean(name = "dataSourceMBean")
|
@ConditionalOnMissingBean(name = "dataSourceMBean")
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
"name": "spring.datasource.jmx-enabled",
|
"name": "spring.datasource.jmx-enabled",
|
||||||
"dataType": "java.lang.Boolean",
|
"dataType": "java.lang.Boolean",
|
||||||
"description": "Enables JMX support (if provided by the underlying pool).",
|
"description": "Enables JMX support (if provided by the underlying pool).",
|
||||||
"defaultValue": true
|
"defaultValue": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "spring.data.elasticsearch.repositories.enabled",
|
"name": "spring.data.elasticsearch.repositories.enabled",
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.springframework.boot.test.EnvironmentTestUtils;
|
|||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.EnableMBeanExport;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
@@ -133,6 +134,7 @@ public class TomcatDataSourceConfigurationTests {
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import(DataSourceAutoConfiguration.class)
|
@Import(DataSourceAutoConfiguration.class)
|
||||||
|
@EnableMBeanExport
|
||||||
protected static class TomcatDataSourceConfiguration {
|
protected static class TomcatDataSourceConfiguration {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -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.time-between-eviction-runs-millis=
|
||||||
spring.datasource.min-evictable-idle-time-millis=
|
spring.datasource.min-evictable-idle-time-millis=
|
||||||
spring.datasource.max-wait=
|
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]
|
# DATASOURCE ({sc-spring-boot-autoconfigure}/dao/PersistenceExceptionTranslationAutoConfiguration.{sc-ext}[PersistenceExceptionTranslationAutoConfiguration]
|
||||||
spring.dao.exceptiontranslation.enabled=true
|
spring.dao.exceptiontranslation.enabled=true
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
@SpringApplicationConfiguration(classes = SampleDataJpaApplication.class)
|
@SpringApplicationConfiguration(classes = SampleDataJpaApplication.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
// 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)
|
||||||
@TestPropertySource(properties = "spring.jmx.enabled:true")
|
@TestPropertySource(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
|
||||||
public class SampleDataJpaApplicationTests {
|
public class SampleDataJpaApplicationTests {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ Base logback configuration provided for compatibility with Spring Boot 1.1
|
|||||||
|
|
||||||
<included>
|
<included>
|
||||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
<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/console-appender.xml" />
|
||||||
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
|
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
|
||||||
<root level="INFO">
|
<root level="INFO">
|
||||||
|
|||||||
Reference in New Issue
Block a user