Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load a properties file into a java.util.Properties?

I need to inject a java.utils.Properties instance into one of my beans. Is there a Spring class which will load the properties file and convert it into a java.utils.Properties instance, ready for injection?

like image 270
Naftuli Kay Avatar asked Dec 21 '22 04:12

Naftuli Kay


1 Answers

Yes, using <util:properties> (see documentation).

Example:

<!-- creates a java.util.Properties instance with values loaded from the supplied location -->
<util:properties id="jdbcConfiguration" location="classpath:com/foo/jdbc-production.properties"/>
like image 96
skaffman Avatar answered Dec 24 '22 01:12

skaffman