PropertyPlaceholderConfigurer to look for DB values and use properties file as fallback

后端 未结 2 503
失恋的感觉
失恋的感觉 2021-01-07 05:57

I\'m wondering if its possible to use the value in DB before properties file in PropertyPlaceholderConfigurer. So what I want to achieve is to load the properties file, and

2条回答
  •  心在旅途
    2021-01-07 06:38

    PropertyPlaceholderConfigurer has a "properties" property that can point to an object that retrieves the database values. See an example here: http://pure-essence.net/2011/02/10/spring-loading-properties-from-database-with-a-twist/

    Also, you'll want to set "ignoreUnresolvablePlaceholders" to true on the bean that config that loads the properties from the database. That way you can add another PropertyPlaceholderConfigurer as a fallback to provide properties that are not found in the database.

提交回复
热议问题