spring-mvc.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
  4. xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans.xsd
  8. http://www.springframework.org/schema/tx
  9. http://www.springframework.org/schema/tx/spring-tx.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. <mvc:annotation-driven validator="validator"></mvc:annotation-driven>
  15. <!-- hibernate validator参数校验 -->
  16. <bean id="validator"
  17. class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
  18. <property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
  19. </bean>
  20. <!-- 方法级别的校验 要校验的方法所在类必须添加@Validated注解 -->
  21. <bean
  22. class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor">
  23. <!-- 可以引用自己的 validator 配置,在本文中(下面)可以找到 validator 的参考配置,如果不指定则系统使用默认的 -->
  24. <property name="validator" ref="validator" />
  25. </bean>
  26. <context:component-scan base-package="com.fuzamei" />
  27. <!-- 配置事务 -->
  28. <bean id="transactionManager"
  29. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  30. <!-- 加载数据源 -->
  31. <property name="dataSource" ref="dataSource"></property>
  32. </bean>
  33. <!-- 开启事务扫描 -->
  34. <tx:annotation-driven transaction-manager="transactionManager"
  35. proxy-target-class="true" />
  36. <!-- 对token拦截验证 (为方便测试,测试环境给注释掉) -->
  37. <!-- <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/*/api/*" />
  38. <bean class="com.fuzamei.interceptor.TokenInterceptor" /> </mvc:interceptor>
  39. </mvc:interceptors> -->
  40. </beans>