Commit 8143743d by Pabolu,Shashidar Committed by Johannes Edmeier

Enable client auto configuration only for web environments

fixes #578
parent 4e7e2b30
......@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
......@@ -38,6 +39,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@Configuration
@EnableConfigurationProperties({AdminProperties.class, AdminClientProperties.class})
@ConditionalOnWebApplication
@Conditional(SpringBootAdminClientEnabledCondition.class)
public class SpringBootAdminClientAutoConfiguration {
......
......@@ -42,6 +42,14 @@ public class SpringBootAdminClientAutoConfigurationTest {
assertTrue(context.getBeansOfType(ApplicationRegistrator.class).isEmpty());
}
@Test
public void nonWebEnvironment() {
load("spring.main.admin.url:http://localhost:8081", "spring.boot.admin.client.enabled:true",
"spring.main.web-environment:false"
);
assertTrue(context.getBeansOfType(ApplicationRegistrator.class).isEmpty());
}
private void load(final String... environment) {
SpringApplication springApplication = new SpringApplication(TestClientApplication.class);
springApplication.addInitializers(new ApplicationContextInitializer<ConfigurableApplicationContext>() {
......
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