420f9e52940566118034f9c807d267f5b049d7ba
[JavaForFun] /
1 <beans xmlns="http://www.springframework.org/schema/beans"\r
2         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
3         xmlns:mvc="http://www.springframework.org/schema/mvc"\r
4         xmlns:context="http://www.springframework.org/schema/context"\r
5         xmlns:util="http://www.springframework.org/schema/util"\r
6         xmlns:p="http://www.springframework.org/schema/p"\r
7         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd\r
8         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd\r
9         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd\r
10         http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">\r
11    \r
12         <!--\r
13                 I am declaring my beans without the automatic annotation. :/\r
14                 Better because we are saving memory but it requires more configuration.\r
15                 \r
16                 See: org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser\r
17                 <mvc:annotation-driven/>\r
18          -->\r
19          \r
20    \r
21         <context:annotation-config />\r
22    \r
23         <context:component-scan base-package="de.spring.webservices.rest"/>\r
24 \r
25     <bean id="jsonObjectMapperFactory" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean" p:indentOutput="true" p:failOnEmptyBeans="false">\r
26         <property name="featuresToDisable">\r
27             <array>\r
28                 <util:constant static-field="com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES"/>\r
29                 <util:constant static-field="com.fasterxml.jackson.databind.MapperFeature.DEFAULT_VIEW_INCLUSION"/>\r
30             </array>\r
31         </property>\r
32     </bean>\r
33 \r
34     <util:list id="messageConverters">\r
35         <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" p:objectMapper-ref="jsonObjectMapperFactory"/>\r
36         <bean class="org.springframework.http.converter.StringHttpMessageConverter" />\r
37     </util:list>\r
38 \r
39 \r
40         <bean name="handlerAdapter"\r
41                 class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">\r
42                 <property name="webBindingInitializer">\r
43                         <bean\r
44                                 class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">\r
45                                 <!-- It enables us to use JSR-303 -->\r
46                                 <property name="validator">\r
47                                         <bean class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>\r
48                                 </property>\r
49                         </bean>\r
50                 </property>\r
51                 <property name="messageConverters" ref="messageConverters" />\r
52                 \r
53                 \r
54                 <property name="requestBodyAdvice">\r
55                         <util:list>\r
56                                 <bean id="requestBodyAdvice" class="org.springframework.web.servlet.mvc.method.annotation.JsonViewRequestBodyAdvice"/>\r
57                         </util:list>\r
58                 </property>\r
59                 \r
60                 \r
61                 <property name="responseBodyAdvice">\r
62                         <util:list>\r
63                                 <bean id="responseBodyAdvice" class="org.springframework.web.servlet.mvc.method.annotation.JsonViewResponseBodyAdvice"/>\r
64                         </util:list>\r
65                 </property>\r
66         </bean>\r
67     \r
68         <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>\r
69 \r
70         <mvc:default-servlet-handler />\r
71         \r
72 </beans>\r