Commit dbec81ca authored by Phillip Webb's avatar Phillip Webb

Disable jmx by default

Change JmxAutoConfiguration so that by default JMX exposure is not
enabled. This matches the Javdoc text.
parent 625d36d0
...@@ -36,7 +36,7 @@ import org.springframework.jmx.export.MBeanExporter; ...@@ -36,7 +36,7 @@ import org.springframework.jmx.export.MBeanExporter;
@Configuration @Configuration
@ConditionalOnClass({ MBeanExporter.class }) @ConditionalOnClass({ MBeanExporter.class })
@ConditionalOnMissingBean({ MBeanExporter.class }) @ConditionalOnMissingBean({ MBeanExporter.class })
@ConditionalOnExpression("${spring.jmx.enabled:true}") @ConditionalOnExpression("${spring.jmx.enabled:false}")
public class JmxAutoConfiguration { public class JmxAutoConfiguration {
@Configuration @Configuration
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
package org.springframework.boot.autoconfigure.jmx; package org.springframework.boot.autoconfigure.jmx;
import org.junit.After; import org.junit.After;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -37,6 +39,9 @@ import static org.junit.Assert.assertNotNull; ...@@ -37,6 +39,9 @@ import static org.junit.Assert.assertNotNull;
*/ */
public class JmxAutoConfigurationTests { public class JmxAutoConfigurationTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
private AnnotationConfigApplicationContext context; private AnnotationConfigApplicationContext context;
@After @After
...@@ -51,6 +56,18 @@ public class JmxAutoConfigurationTests { ...@@ -51,6 +56,18 @@ public class JmxAutoConfigurationTests {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
this.context.register(JmxAutoConfiguration.class); this.context.register(JmxAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
this.thrown.expect(NoSuchBeanDefinitionException.class);
this.context.getBean(MBeanExporter.class);
}
@Test
public void testEnabledMBeanExport() {
MockEnvironment env = new MockEnvironment();
env.setProperty("spring.jmx.enabled", "true");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(env);
this.context.register(JmxAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(MBeanExporter.class)); assertNotNull(this.context.getBean(MBeanExporter.class));
} }
......
...@@ -14,4 +14,6 @@ shell.ssh.port: 2222 ...@@ -14,4 +14,6 @@ shell.ssh.port: 2222
shell.auth: spring shell.auth: spring
#shell.auth: key #shell.auth: key
#shell.auth.key.path: ${user.home}/test/id_rsa.pub.pem #shell.auth.key.path: ${user.home}/test/id_rsa.pub.pem
#shell.auth: simple #shell.auth: simple
\ No newline at end of file spring.jmx.enabled: true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment