mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Guard IntegrationJmxConfiguration if no mBeanServer is available
Closes gh-12966
This commit is contained in:
parent
4585bc846a
commit
08bc306a61
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -22,6 +22,7 @@ import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@ -70,6 +71,7 @@ public class IntegrationAutoConfiguration {
|
||||
@Configuration
|
||||
@ConditionalOnClass(EnableIntegrationMBeanExport.class)
|
||||
@ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT)
|
||||
@ConditionalOnBean(MBeanServer.class)
|
||||
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
protected static class IntegrationJmxConfiguration
|
||||
implements EnvironmentAware, BeanFactoryAware {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -82,6 +82,16 @@ public class IntegrationAutoConfigurationTests {
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noMBeanServerAvailable() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(IntegrationAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(TestGateway.class)).isNotNull();
|
||||
assertThat(this.context.getBean(IntegrationComponentScanAutoConfiguration.class))
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parentContext() {
|
||||
load();
|
||||
|
Loading…
Reference in New Issue
Block a user