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

前端 未结 6 1029
囚心锁ツ
囚心锁ツ 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条回答
  •  死守一世寂寞
    2021-02-02 02:46

    Your beans.xml file should have a PropertyPlaceholderConfigurer:

    
        
            
                classpath:some/pkg/resource.properties
            
        
        
        
            
                value
            
        
    
    

    And then you can reference the properties as such elsewhere in the beans.xml:

    
        ....
    
    

    For an article about this, check out http://almaer.com/blog/spring-propertyplaceholderconfigurer-a-nice-clean-way-to-share

提交回复
热议问题