简体   繁体   English

春季propertySource

[英]Spring propertySource

I am working on a legacy application here and I am trying to use the Spring @PropertySource annotation. 我在这里处理旧版应用程序,并且尝试使用Spring @PropertySource批注。

The problem I am facing is the file name is build.dev.properties and my configuration is: 我面临的问题是文件名为build.dev.properties,而我的配置是:

@PropertySource("classpath:build.${target_env}.properties")

target_env is set to Dev so it looks for build.Dev.Properties which does not exists , I can't change the name of the file or the target_env is there a way I can have in property source to ignore the casing. target_env设置为Dev,因此它将查找不存在的build.Dev.Properties ,我无法更改文件名,或者target_env是否可以在属性源中忽略大小写。

The String you supply can contain Spring Expression Language, I am just guessing but you can try 您提供的字符串可以包含Spring Expression Language,我只是在猜测,但是您可以尝试

@PropertySource("classpath:build.${target_env.toLowerCase()}.properties")

or 要么

@PropertySource("classpath:build.${target_env}.toLowerCase().properties")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM