org.springframework.core.env.Environment with-Spring Cloud Config Server-external properties文件
我在Git上创建了一个个人存储库,其中保存了application.properties文件 我已经创建了一个云配置服务器(“my-config-server”),并使用了git存储库url 我已经将本应访问外部属性文件的spring boot应用程序绑定到Git存储库org.springframework.core.env.Environment with-Spring Cloud Config Server-external properties文件,spring,git,Spring,Git,我在Git上创建了一个个人存储库,其中保存了application.properties文件 我已经创建了一个云配置服务器(“my-config-server”),并使用了git存储库url 我已经将本应访问外部属性文件的spring boot应用程序绑定到Git存储库 @javax.jws.WebService( serviceName = "myService", portName = "my_service",
@javax.jws.WebService(
serviceName = "myService",
portName = "my_service",
targetNamespace = "urn://vdc.com/xmlmessaging/SD",
wsdlLocation = "classpath:myService.wsdl",
endpointInterface = "com.my.service.SDType")
@ConfigurationProperties
public class SDTypeImpl implements SDType {
/*It has various services implementation that use following method**/
private SDObj getObj (BigDecimal value) {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(
SDTypeImpl.class);
SDObj obj = context.getBean(SDPropertiesUtil.class).getObj(value);
context.close();
return obj;
}
}
另一类:
public class SDPropertiesUtil {
@Autowired
public Environment env;
public SDObj getObj(BigDecimal value) {
String valueStr = env.getProperty(value.toString());
/*do logic*/
}
但是,我得到的'valueStr'为null
我的应用程序启动,云上的配置服务器从我的git存储库加载属性文件。
从云日志中,在推送应用程序后:
PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource [name='configClient'], MapPropertySource [name='ssh://blah blah blah.git/application.properties']]]
我的应用程序无法通过SpringCloudConfigServer访问外部属性文件 那么,您的属性实际上是可以放入
BigDecimal
中的数字吗?我的属性看起来像“4.1234=SSN不是9位”。我还尝试将其转换为字符串而不是BigD,然后将其转换为BigD,但没有成功