Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

spring

grails

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

Is this possible at all ? Is there an equivalent of the xml import tag in grails bean dsl ? I thought about adding the import ... in applicationContext.xml but I'm not sure that's the right place to do it.

Thanks in advance,

Philippe

like image 716
Philippe Avatar asked Mar 22 '12 14:03

Philippe


People also ask

How can we load all the bean configuration files?

You may load multiple Spring bean configuration files in the code : ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"Spring-Common. xml", "Spring-Connection. xml","Spring-ModuleA.

What is the use of beans XML?

The beans. xml file is the bean archive descriptor for CDI applications. It can be used for any CDI compliant container, such as Weld which is included in WildFly application server.

What is an XML bean?

XMLBeans is a technology for accessing XML by binding it to Java types. XMLBeans provides several ways to get at the XML, including: Through XML schema that has been compiled to generate Java types that represent schema types.


1 Answers

You can import the beans in an XML file into resources.groovyusing

beans = {
    importBeans('classpath:/applicationContext-services.xml')
}
like image 113
Dónal Avatar answered Oct 02 '22 20:10

Dónal