Reputation: 65
I have an application using Java config in Spring MVC. I have a WebAppInitializer and on Startup method I am using AnnotationConfigWebApplicationContext to load the rootContext.
From the Startup method of WebAppInitializer, how do I load a Client Jar that has applicationContext.xml file. Basically I am looking at something like this.
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(MyAppContext.class);
Looking at something Like this.
rootContext.register(applicationContext.xml);
Upvotes: 0
Views: 662
Reputation: 279930
The whole point of AnnotationConfigWebApplicationContext
is to have an ApplicationContext
configured through annotations. So there is no direct method for parsing and importing XML configurations.
What you can do is define a @Configuration
type that imports an XML resource
@Configuration
@ImportResource(value = "classpath:application.xml")
class XmlConfig {}
and register that
rootContext.register(XmlConfig.class);
Upvotes: 2