<?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:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:aop="http://www.springframework.org/schema/aop"
	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/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">

	<!-- 扫描controller -->
	<context:component-scan base-package="**.*controller" />
	<context:annotation-config />
	<bean id="swagger2Config" class="springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration"/>

	<!-- 启动aop注解基于类的代理（这时需要cglib库），如果proxy-target-class属值被设置为false或者这个属性被省略，那么标准的JDK 基于接口的代理将起作用 -->
	<aop:config proxy-target-class="true"/>

	<!-- 返回ResponseBody响应类型 -->
	<mvc:annotation-driven>
		<mvc:message-converters>
			<bean class="org.springframework.http.converter.StringHttpMessageConverter">
				<property name="supportedMediaTypes">
					<list>
						<value>text/html;charset=UTF-8</value>
					</list>
				</property>
			</bean>
		</mvc:message-converters>
	</mvc:annotation-driven>

	<!-- Jsp视图 -->
	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/jsp" />
		<property name="suffix" value=".jsp" />
		<property name="contentType" value="text/html; charset=utf-8" />
		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
	</bean>

	<!-- i18n国际化 -->
	<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
		<!-- 找不到key时用key作为返回值 -->
		<property name="useCodeAsDefaultMessage" value="false" />
		<!-- 资源刷新时间 -->
		<property name="cacheSeconds" value="60" />
		<!-- 资源文件列表 -->
		<property name="basenames">
			<list>
				<value>classpath:i18n/messages</value>
			</list>
		</property>
		<property name="defaultEncoding" value="UTF-8" />
	</bean>

	<!-- 配置静态资源，不被DispatcherServlet处理，增加缓存时间10秒 -->
	<mvc:resources mapping="/favicon.ico" location="/favicon.ico"/>
	<mvc:resources mapping="/resources/**" location="/resources/" cache-period="10"/>
	<mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/>
	<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
	
	<!-- 上传文件配置 20*1024*1024即20M resolveLazily属性启用是为了推迟文件解析，以便捕获文件大小异常 -->
	<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="maxUploadSize" value="20971520" />
		<property name="defaultEncoding" value="UTF-8" />
		<property name="resolveLazily" value="true" />
	</bean>

</beans>