Populating a spring bean using a constructor-arg field

后端 未结 2 1083
小蘑菇
小蘑菇 2021-02-02 11:59

How can i inject a properties file containing a Map to be used as additional constructor arg using the field.

With a Map being loaded from a properties file

the

2条回答
  •  暖寄归人
    2021-02-02 12:53

    Something like this:

    
       
    
    
    
    
         
         
    
    

    This takes advantage of the ability to create beans using arbitrary static factory methods, in this case using loadConfigurations() as a factory method to create the configuration bean, which is then injected into the proper constructor of EmbeddedGraphDatabase.

提交回复
热议问题