spring-web-context.xml
5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<mvc:resources mapping="/html/**" location="/html/" />
<aop:aspectj-autoproxy />
<context:property-placeholder ignore-resource-not-found="true" location="classpath*:config.properties" />
<context:component-scan base-package="com.yohoufo" />
<!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="false">
<ref bean="stringConverter" />
<ref bean="jsonConverter" />
</mvc:message-converters>
</mvc:annotation-driven>
<bean id="stringRedisSerializer"
class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
<!-- byte[] 转换器 -->
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
<!--字符串转换器 -->
<bean id="stringConverter" class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<!-- json转换器 application/json -->
<bean id="jsonConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json;charset=UTF-8"/>
<property name="fastJsonConfig" ref="fastJsonConfig" />
</bean>
<bean id="fastJsonConfig" class="com.alibaba.fastjson.support.config.FastJsonConfig">
<property name="serializerFeatures">
<array value-type="com.alibaba.fastjson.serializer.SerializerFeature">
<value>WriteEnumUsingToString</value>
<value>DisableCircularReferenceDetect</value>
</array>
</property>
</bean>
<bean id="DisableCircularReferenceDetect" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.DisableCircularReferenceDetect"></property>
</bean>
<!-- 配置MultipartResolver 用于文件上传 使用spring的CommosMultipartResolver -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8"></property>
<property name="resolveLazily" value="true"></property>
</bean>
<task:annotation-driven executor="myExecutor"
scheduler="myScheduler" />
<task:executor id="myExecutor" pool-size="5" />
<task:scheduler id="myScheduler" pool-size="10" />
<bean id="handlebarsViewResolver" class="com.github.jknack.handlebars.springmvc.HandlebarsViewResolver">
<property name="prefix" value="classpath:/conf/template" />
<property name="suffix" value=".html" />
<property name="contentType" value="text/html;charset=UTF-8" />
</bean>
<!-- api文档配置 start -->
<!-- api文档配置 注解扫描器 -->
<bean id="yohoApiAnnotationScanner" class="com.yoho.tools.docs.YohoApiAnnotationScanner" >
<!-- api文档配置 类名过滤器(正则)多个模式用英文逗号隔开 -->
<property name="classFilterReg" value="${yoho.api.docs.filter:^.*$}" />
<property name="scanSwitch" value="${yoho.api.docs.switch:off}" />
</bean>
<!-- api文档配置 end -->
<bean id="ufoServiceCaller" class="com.yohoufo.common.caller.UfoServiceCaller" />
<bean id="eventBusPublisher" class="com.yohoufo.common.alarm.EventBusPublisher">
<constructor-arg name="executor" ref="executor"/>
</bean>
<task:executor id="executor" pool-size="20" />
<bean id="accessStatistics" class="com.yohoufo.common.interceptor.AccessStatistics" />
<!--Spring mvc 拦截器-->
<mvc:interceptors>
<ref bean="trace.traceInterceptor"/>
<ref bean="threadProfileInterceptor"/>
<ref bean="localIpInterceptor" />
<ref bean="securityInterceptor" />
<ref bean="signatureVerifyInterceptor" />
<ref bean="innerApiInterceptor" />
<ref bean="accessStatistics"/>
</mvc:interceptors>
</beans>