More @Conditionals to prevent error if bootstrap disabled
If user disables bootstrap configuration (spring.cloud.bootstrap.enabled:false) we have to anticipate some beans will be missing. Fixes gh-65
This commit is contained in:
@@ -42,20 +42,22 @@ import org.springframework.context.annotation.Configuration;
|
||||
@ConditionalOnClass(EnvironmentEndpoint.class)
|
||||
@ConditionalOnProperty(value = "endpoints.env.enabled", matchIfMissing = true)
|
||||
@ConditionalOnWebApplication
|
||||
@ConditionalOnBean({ EnvironmentEndpoint.class, RefreshEndpoint.class })
|
||||
@AutoConfigureAfter({ WebMvcAutoConfiguration.class, EndpointAutoConfiguration.class })
|
||||
@ConditionalOnBean(RestartEndpoint.class)
|
||||
@AutoConfigureAfter({ WebMvcAutoConfiguration.class, EndpointAutoConfiguration.class, RefreshAutoConfiguration.class })
|
||||
public class EnvironmentEndpointAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
private RestartEndpoint restartEndpoint;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(EnvironmentEndpoint.class)
|
||||
public EnvironmentManagerMvcEndpoint environmentManagerEndpoint(
|
||||
EnvironmentEndpoint delegate, EnvironmentManager environment) {
|
||||
return new EnvironmentManagerMvcEndpoint(delegate, environment);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(RefreshEndpoint.class)
|
||||
public MvcEndpoint refreshMvcEndpoint(RefreshEndpoint endpoint) {
|
||||
return new GenericPostableMvcEndpoint(endpoint);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.springframework.cloud.bootstrap;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.cloud.bootstrap.BootstrapDisabledAutoConfigurationIntegrationTests.Application;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = Application.class)
|
||||
@IntegrationTest({ "server.port:0", "spring.cloud.bootstrap.enabled:false" })
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("test")
|
||||
public class BootstrapDisabledAutoConfigurationIntegrationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@Configuration
|
||||
protected static class Application {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
message: Hello scope!
|
||||
delay: 0
|
||||
# debug: true
|
||||
debug: true
|
||||
#logging.level.org.springframework.web: DEBUG
|
||||
#logging.level.org.springframework.context.annotation: DEBUG
|
||||
@@ -22,7 +22,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@IntegrationTest({"server.port:0", "spring.config.name:configserver", "spring.cloud.config.server.git.uri:file:./target/repos/config-repo"})
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("test")
|
||||
public class ApplicationTests {
|
||||
public class VanillaConfigServerIntegrationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
private int port;
|
||||
Reference in New Issue
Block a user