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

4

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

1个回答

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"/>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接