我有一个 FeignClient 接口,我想从我的application.yml
文件中加载一个名称,所以我这样做了:
@FeignClient(name = "${edgeServer}", configuration = BeansConfiguration.class)
在我的yml
文件中:
edgeServer: edge-server
但我在运行时遇到异常:
java.lang.IllegalStateException: org.springframework.util.Assert.state(Assert.java:70) 的服务 id 不是合法主机名 (${edgeServer}) ~[spring-core-4.3.10.RELEASE.jar:4.3. 10.RELEASE] 在 org.springframework.cloud.netflix.feign.FeignClientsRegistrar.getName(FeignClientsRegistrar.java:238) ~[spring-cloud-netflix-core-1.3.1.RELEASE.jar:1.3.1.RELEASE] 在org.springframework.cloud.netflix.feign.FeignClientsRegistrar.registerFeignClient(FeignClientsRegistrar.java:181) ~[spring-cloud-netflix-core-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.cloud .netflix.feign.FeignClientsRegistrar.registerFeignClients(FeignClientsRegistrar.java:167) ~[spring-cloud-netflix-core-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.cloud.netflix.feign。 FeignClientsRegistrar.registerBeanDefinitions(FeignClientsRegistrar.java:92) ~[spring-cloud-netflix-core-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:359) ~[spring-context -4.3.10.RELEASE.jar:4.3.10.RELEASE] 在 org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143) ~[spring-context-4.3.10.RELEASE.jar:4.3. 10.RELEASE] 在 org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] 在 org.springframework.context。注释.ConfigurationClassPostProcessor。processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320)~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)~[spring -context-4.3.10.RELEASE.jar:4.3.10.RELEASE] 在 org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270) ~[spring-context-4.3.10.RELEASE.jar: 4.3.10.RELEASE] 在 org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] 在 org.springframework。 context.support.AbstractApplicationContext。invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[spring -context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
那么这个问题有什么解决方案,否则我怎样才能让我的 name 属性从我的 yml 属性中注入?
谢谢