spring-web-context.xml 2.14 KB
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans    
                        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd    
                        http://www.springframework.org/schema/context    
                        http://www.springframework.org/schema/context/spring-context-3.1.xsd    
                        http://www.springframework.org/schema/util        
                     http://www.springframework.org/schema/util/spring-util-3.2.xsd  
                        http://www.springframework.org/schema/mvc    
                        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

	<!-- Spring扫描目录,通过注解的方式注入bean,只扫描本工程的目录 -->
	<context:component-scan base-package="com.yoho" />

	<context:property-placeholder location="classpath*:config.properties,classpath*:zookeeper.properties" />

	<!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->
	<mvc:annotation-driven>
		<mvc:message-converters>
			<ref bean="stringConverter" />
			<ref bean="jsonConverter" />
		</mvc:message-converters>
	</mvc:annotation-driven>

	<!--字符串转换器-->
	<bean id="stringConverter"
		class="org.springframework.http.converter.StringHttpMessageConverter">
		<property name="supportedMediaTypes">
			<list>
				<value>text/plain;charset=UTF-8</value>
			</list>
		</property>
	</bean>

	<!-- json转换器  application/json -->
	<bean id="jsonConverter"
		class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
	</bean>
	
    <bean class="com.yoho.error.exception.handler.ServiceGlobalExceptionHandler" />
	<bean id="springContextUtil" class="com.yoho.yhmessage.sms.util.SpringContextUtil" />
	<mvc:interceptors>
		<ref bean="trace.traceInterceptor"/>
		<ref bean="threadProfileInterceptor"/>
	</mvc:interceptors>

</beans>