Spring properties that depend on other properties

后端 未结 1 506
囚心锁ツ
囚心锁ツ 2021-01-01 09:55

I would like to have properties, that I can reference via @Value in spring beans, that can only be created dependend on other properties. In particular I am having a propert

相关标签:
1条回答
  • 2021-01-01 10:36

    Spring can combine properties

    myDir=/path/to/mydir 
    myFile=${myDir}/myfile.txt
    

    You can also use a default value without defining your myFile in the properties at first:

    Properties file

    myDir=/path/to/mydir
    

    In class:

    @Value("#{myFile:${myDir}/myfile.txt}")
    private String myFileName;
    
    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题