Spring properties file as xml

后端 未结 2 758
情话喂你
情话喂你 2021-01-06 02:08

I have properties file config.properties where are stored some application wide properties. And I have imported it using property placeholder:



        
2条回答
  •  暖寄归人
    2021-01-06 02:36

    In addition to the other answer here, I have also seen xml properties loaded directly as named properties files:

    The spring file contains:

    
    

    This can then be accessed via springs expression language as:

    "#{myXmlProps['key1']}"
    

    And injected into Strings in classes with:

    @Value("#{myXmlProps['key1']}")
    private String aValueForKey1;
    

提交回复
热议问题