1 <beans xmlns="http://www.springframework.org/schema/beans"
2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns:mvc="http://www.springframework.org/schema/mvc"
4 xmlns:context="http://www.springframework.org/schema/context"
5 xmlns:util="http://www.springframework.org/schema/util"
6 xmlns:p="http://www.springframework.org/schema/p"
8 http://www.springframework.org/schema/beans
9 http://www.springframework.org/schema/beans/spring-beans.xsd
10 http://www.springframework.org/schema/mvc
11 http://www.springframework.org/schema/mvc/spring-mvc.xsd
12 http://www.springframework.org/schema/context
13 http://www.springframework.org/schema/context/spring-context.xsd
14 http://www.springframework.org/schema/util
15 http://www.springframework.org/schema/util/spring-util.xsd">
18 I am declaring my beans without the automatic annotation. :/
19 Better because we are saving memory but it requires more configuration.
21 See: org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser
22 <mvc:annotation-driven/>
26 <context:annotation-config />
28 <context:component-scan base-package="de.spring.webservices.rest"/>
31 Required beans for generating XML responses from Java objects using JAXB annotations
32 Jackson also works but it doesn't generate XML with namespaces... O.o
34 This implementation will be slower than the one using Jackson :( but I am going to use it just for WADL generation :)
36 <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
37 <property name="packagesToScan" value="org.jvnet.ws.wadl"/>
39 <bean id="jaxbConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
40 <constructor-arg ref="jaxbMarshaller" />
43 <!-- Required beans for generating JSON responses from Java objects -->
44 <bean id="jsonObjectMapperFactory" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"
45 p:indentOutput="true" p:failOnEmptyBeans="false">
46 <property name="featuresToDisable">
48 <util:constant static-field="com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES"/>
49 <util:constant static-field="com.fasterxml.jackson.databind.MapperFeature.DEFAULT_VIEW_INCLUSION"/>
54 <util:list id="messageConverters">
55 <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" p:objectMapper-ref="jsonObjectMapperFactory"/>
56 <ref bean="jaxbConverter" />
57 <bean class="org.springframework.http.converter.StringHttpMessageConverter" />
61 <bean name="handlerAdapter"
62 class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
63 <property name="webBindingInitializer">
65 class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
66 <!-- It enables us to use JSR-303 -->
67 <property name="validator">
68 <bean class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
72 <property name="messageConverters" ref="messageConverters" />
75 <property name="requestBodyAdvice">
77 <bean id="requestBodyAdvice" class="org.springframework.web.servlet.mvc.method.annotation.JsonViewRequestBodyAdvice"/>
82 <property name="responseBodyAdvice">
84 <bean id="responseBodyAdvice" class="org.springframework.web.servlet.mvc.method.annotation.JsonViewResponseBodyAdvice"/>
89 <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
91 <mvc:default-servlet-handler />