Reading a dynamic property map into Spring managed bean

后端 未结 4 2114
悲哀的现实
悲哀的现实 2021-02-05 23:53

I have a properties file like this:

my.properties file:
app.One.id=1
app.One.val=60

app.Two.id=5
app.Two.val=75

And I read these values into a

4条回答
  •  遥遥无期
    2021-02-06 00:47

    Maybe I did not fully understand the issue here...
    What about a simplified approach?

    my.properties file:
    1=60
    5=75
    

    Application Context

    
        
            
            classpath: my.properties
            
        
     
    
        
    
    

    Java Bean

    public class MyClass {
        private Map myMap;
    
        public void setMyMap(Map myMap) {
            this.myMap = myMap;
        }
    
        public Map getMyMap(){
            return myMap;
        }
    }
    

提交回复
热议问题