diff --git a/pom.xml b/pom.xml
index 7998ab704..8f0cc16bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,6 +80,14 @@
io.spring.javaformat
spring-javaformat-maven-plugin
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.6
+
+ true
+
+
diff --git a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java
index e340e420d..160741a20 100644
--- a/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java
+++ b/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java
@@ -40,12 +40,15 @@
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.env.Environment;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertySource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
+import org.springframework.web.context.support.StandardServletEnvironment;
/**
* @author Spencer Gibb
@@ -64,6 +67,10 @@ class FeignClientsRegistrar
private Environment environment;
+ private static final String PREFIX = "appoint.";
+
+ private static final String SUFFIX = ".url";
+
FeignClientsRegistrar() {
}
@@ -209,9 +216,9 @@ private void registerFeignClient(BeanDefinitionRegistry registry,
BeanDefinitionBuilder definition = BeanDefinitionBuilder
.genericBeanDefinition(FeignClientFactoryBean.class);
validate(attributes);
- definition.addPropertyValue("url", getUrl(attributes));
- definition.addPropertyValue("path", getPath(attributes));
String name = getName(attributes);
+ definition.addPropertyValue("url", getUrl(attributes, name));
+ definition.addPropertyValue("path", getPath(attributes));
definition.addPropertyValue("name", name);
String contextId = getContextId(attributes);
definition.addPropertyValue("contextId", contextId);
@@ -282,6 +289,28 @@ private String getUrl(Map attributes) {
return getUrl(url);
}
+ private String getUrl(Map attributes, String name) {
+ String realName = PREFIX + name + SUFFIX;
+ String url = resolve((String) attributes.get("url"));
+ Map propertyMap;
+ if (!StringUtils.hasText(url)) {
+ String[] activeProfiles = this.environment.getActiveProfiles();
+ String config = "applicationConfig: [classpath:/bootstrap-"
+ + activeProfiles[0] + ".yml]";
+ MutablePropertySources propertySources = ((StandardServletEnvironment) this.environment)
+ .getPropertySources();
+ PropertySource> propertySource = propertySources.stream()
+ .filter(p -> p.getName().equals(config)).findFirst().orElse(null);
+ if (propertySource != null) {
+ propertyMap = (Map) propertySource.getSource();
+ if (propertyMap.containsKey(realName)) {
+ url = propertyMap.get(realName).toString();
+ }
+ }
+ }
+ return getUrl(url);
+ }
+
private String getPath(Map attributes) {
String path = resolve((String) attributes.get("path"));
return getPath(path);
diff --git a/spring-cloud-openfeign-dependencies/pom.xml b/spring-cloud-openfeign-dependencies/pom.xml
index ab0c56f7f..1876b6af0 100644
--- a/spring-cloud-openfeign-dependencies/pom.xml
+++ b/spring-cloud-openfeign-dependencies/pom.xml
@@ -102,6 +102,18 @@
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.6
+
+ true
+
+
+
+
spring