一个关于Spring注入属性文件的简单问题,针对final属性。
我有一个属性文件,我想要在里面存储文件路径。通常当我使用属性文件时,我会使用以下方式设置类属性:
private @Value("#{someProps['prop.field']}") String someAttrib ;
那么在我的spring.xml
文件中,我将会有类似以下的内容:
<util:properties id="someProps"
location="classpath:/META-INF/properties/somePropFile.properties" />
这很好用,简单易懂,可以让代码整洁美观。但是我不确定在尝试将属性值注入最终类属性时最整洁的模式是什么?
显然像这样:
private static final @Value("#{fileProps['dict.english']}") String DICT_PATH;
不会起作用。还有其他方法吗?