我有一个像这样的属性文件:
frame.server.dev=mark.is.cool
frame.server.test=chris.is.cool
frame.server.qa=mitch.is.cool
frame.server.prod=cory.is.cool
我需要根据环境注入(inject)正确的值。由于我们有一个 Ear 文件,需要从一个环境移动到另一个环境,所以我需要执行以下操作:
<util:properties id="props" location="classpath:ILog-application.properties"/>
然后:
@Value ("props.frame.server.#{systemProperties.the.environment}")
private String server;
但是,我无法让 systemProperties 工作,也无法让它在常量之后注入(inject)任何内容。有什么帮助吗?
最佳答案
应该是
@Value ("#{props['frame.server.' + systemProperties['the.environment']]}")
关于java - 通过 Spring by Environment 注入(inject)属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2538605/