gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 05:24:34 24 4
gpt4 key购买 nike

我有一个声明

`@PropertySource("${env}.properties")` 

其中“env”是我的命令行参数。

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

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

最佳答案

你可以像这样使用spring表达语言

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

或者类似的东西

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

关于java - 如何在Java Spring @PropertySource注释中将字符串更改为小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58919267/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com