我有一个多租户环境,所以我需要在运行时更改 application.properties 中的一些路径以使用特定租户的文件夹。例如,在我的应用程序属性中:
image.avatars=C:/Users/Public/Pictures/Sample Pictures/${tenant}/Avatars/
在我的课堂上,我使用
@Autowired
private Environment env;
private static final String DIRECTORY_USER_IMAGE = "image.avatars";
.....Method
env.getRequiredProperty(DIRECTORY_USER_IMAGE)
我读了关于,但我不明白它如何在我的情况下使用,因为它只有一个这样的参数。
有没有一种简单的方法来更改占位符而不操作String(带替换)?
我认为 env.resolveRequiredPlaceholders 需要属性的名称和占位符的 varargs,但它是不同的。谢谢env.resolveRequiredPlaceholdersenv.resolveRequiredPlaceholders(TenantContext.getCurrentTenant())
开满天机
潇潇雨雨
相关分类