Programmatic access to properties created by property-placeholder

后端 未结 9 2400
长情又很酷
长情又很酷 2020-11-29 20:21

I\'m reading properties file using context:property-placeholder. How can I access them programatically (@Value doesn\'t work - I d

9条回答
  •  悲哀的现实
    2020-11-29 20:59

    This works if you need to scan multiple locations for your properties ...

    
        
            
                classpath:yourProperties.properties
                file:../conf/yourProperties.properties
                file:conf/yourProperties.properties
                file:yourProperties.properties
            
        
        
    
    
    

    And then in your actual classes ...

    @Autowired
    Properties yourProperties;
    

    Tested using Spring 5.1.4

提交回复
热议问题