From 86d515282ef64fa5b2db895b286829003010d990 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 15 Feb 2016 15:58:50 +0000 Subject: [PATCH] Import the autoconfig for server properties Otherwise there can be duplicate beans with the same type and different names, becasue the autoconfig does not (for some reason) use @EnableConfigurationProperties to create the ServerProperties bean. It isn't an issue until someone writes some autoconfig that itself imports the ZuulConfiguration (i.e. regular concious users of @EnableZuulServer do not see any problems and hence no tests fail here or in integration projects). Fixes gh-821 --- .../cloud/netflix/zuul/ZuulConfiguration.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java index ac302097..20de333f 100644 --- a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java +++ b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java @@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.web.ErrorController; import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration; import org.springframework.boot.context.embedded.ServletRegistrationBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cloud.client.actuator.HasFeatures; @@ -42,6 +43,7 @@ import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.event.ContextRefreshedEvent; import com.netflix.zuul.ZuulFilter; @@ -52,8 +54,10 @@ import com.netflix.zuul.http.ZuulServlet; * @author Dave Syer */ @Configuration -@EnableConfigurationProperties({ ZuulProperties.class, ServerProperties.class }) +@EnableConfigurationProperties({ ZuulProperties.class }) @ConditionalOnClass(ZuulServlet.class) +// Make sure to get the ServerProperties from the same place as a normal web app would +@Import(ServerPropertiesAutoConfiguration.class) public class ZuulConfiguration { @Autowired