Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Java Spring@PropertySource注释中将字符串更改为小写_Java_Spring_Annotations - Fatal编程技术网

如何在Java Spring@PropertySource注释中将字符串更改为小写

如何在Java Spring@PropertySource注释中将字符串更改为小写,java,spring,annotations,Java,Spring,Annotations,我有一份声明 `@PropertySource("${env}.properties")` 其中“env”是我的命令行参数 如果env=QA,这将导致我的配置文件名为QA.properties 我想确保配置文件的名称总是小写(即“qa.properties”)。您可以像这样使用类似spring的表达式语言 @PropertySource("classpath:build.${env.toLowerCase()}.properties") 或者类似的 @PropertySource("cl

我有一份声明

`@PropertySource("${env}.properties")` 
其中“env”是我的命令行参数

如果env=QA,这将导致我的配置文件名为QA.properties


我想确保配置文件的名称总是小写(即“qa.properties”)。

您可以像这样使用类似spring的表达式语言

@PropertySource("classpath:build.${env.toLowerCase()}.properties") 
或者类似的

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

谢谢你的回答,但它不适合我。获取错误:
“在第一种情况下无法解析值“classpath…”中的占位符“env.toLowerCase()”
“在第二种情况下无法打开类路径资源[build.dev.toLowerCase().properties],因为它不存在。”
。请尝试删除该生成。部分