将属性文件加载到java.util.Properties中?

Naf*_*Kay 4 java spring properties

我需要在java.utils.Properties我的一个bean中注入一个实例.是否有一个Spring类将加载属性文件并将其转换为java.utils.Properties实例,准备注入?

ska*_*man 11

是的,使用<util:properties>(见文档).

例:

<!-- creates a java.util.Properties instance with values loaded from the supplied location -->
<util:properties id="jdbcConfiguration" location="classpath:com/foo/jdbc-production.properties"/>
Run Code Online (Sandbox Code Playgroud)