Is it possible to import an external XML bean configuration file into .groovy resources?

In my grails application, I have spring beans defined in resources.groovy. Now I also have an xml file with an already defined bunch of beans, and I would like to use them as instead of recreating each bean in a dsl bean.

Is this even possible? Is there an equivalent xml import tag in grails bean dsl? I was thinking about adding an import ... to applicationContext.xml, but I'm not sure if this is the right place for this.

Thanks in advance,

Philip

+5
source share
3 answers

You can import beans into an XML file resources.groovyusing

beans = {
    importBeans('classpath:/applicationContext-services.xml')
}
+11
source

resources.xml . xml - , , Groovy.

+2

To make this work on grails 1.3.7, I really needed to do something like this:

beans {

   switch(Environment.current) {

      case Environment.DEVELOPMENT:
         importBeans('file:grails-app/conf/spring/messaging.xml')
         break
      default:
         importBeans 'classpath*:WEB-INF/spring/messaging.xml'
         break
   }

}

I needed * after the class path so that it could be captured when launched on the application server. Does not work in development, although, therefore, there is another accessor for it

See http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/core/io/support/PathMatchingResourcePatternResolver.html for documentation on compliance syntax.

+1
source

All Articles