How can I use a custom PropertyPlaceholderConfigurer in Grails

472 views Asked by At

My project creates war files that get deployed in different tomcat instances. Instead of using properties files in all of these locations and remembering to update the property values in these files we extended Springs PropertyPlaceholderConfigurer to read properties from a Mongo. This works well for our java/spring based wars. The problem is trying to get our grails applications to use this bean. I have included the bean in the spring/resources.groovy(or xml) but grails does not honor the bean and it gets overridden (or overlooked) with it's own GrialsPlaceholderConfigurer. Is there a way to tell grails to use our own Configurer?

2

There are 2 answers

1
lifeisfoo On

Seems that it's possible from grails 1.0. I never used it but adding the following code in your configuration should work:

beans {
    addBeanFactoryPostProcessor(new PropertyPlaceholderConfigurer())
}

See also this test in the grails source code base.

0
lmcadory On

I was able to solve this by just creating a bean. The original developer didn't understand Grails. Once I really looked at it I was able to the custom Configurer to work.