How do you configure a Spring bean container to load a Java property file?

前端 未结 6 1093
囚心锁ツ
囚心锁ツ 2021-02-02 01:48

How do you configure a Spring bean container (or application context) to load a Java property file?

JavaWorld article Smartly Load Your Properties explains how to load p

6条回答
  •  Happy的楠姐
    2021-02-02 02:43

    If you want to reference the object as an instance of java.util.Properties, you should do the following:

    
        true
        
            
                classpath:property-file.properties
            
        
    
    

    This allows you to reference the Spring bean properties as an instance of java.util.Properties. You can even have it merge together multiple properties files by adding more values to location. See this description of resource strings for information about what types of values Spring will accept for location. If you are wanting to use ${} style substitutions in the Spring XML, you can see there are a number of other answers describing how to do that.

提交回复
热议问题