Setup Java configuration into the web.xml

This commit is contained in:
Antoine Rey 2014-07-01 08:00:09 +02:00
parent a04d789db9
commit 521155c3a6
3 changed files with 38 additions and 9 deletions

View file

@ -0,0 +1,10 @@
package org.springframework.samples.petclinic.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
@ImportResource("classpath:spring/mvc-core-config.xml")
public class MvcCoreConfig {
}

View file

@ -0,0 +1,10 @@
package org.springframework.samples.petclinic.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
@ImportResource({"classpath:spring/business-config.xml", "classpath:spring/tools-config.xml"})
public class RootApplicationContextConfig {
}

View file

@ -28,13 +28,18 @@ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
-->
<!--
- Location of the XML file that defines the root application context.
- Location of the Java configuration that defines the root application context.
- Applied by ContextLoaderListener.
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/business-config.xml, classpath:spring/tools-config.xml</param-value>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>org.springframework.samples.petclinic.config.RootApplicationContextConfig</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
@ -46,9 +51,13 @@ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
<servlet>
<servlet-name>petclinic</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/mvc-core-config.xml</param-value>
<param-value>org.springframework.samples.petclinic.config.MvcCoreConfig</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>