applicationContext.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans default-lazy-init="false"
  3. xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:tx="http://www.springframework.org/schema/tx"
  7. xmlns:util="http://www.springframework.org/schema/util"
  8. xmlns:mvc="http://www.springframework.org/schema/mvc"
  9. xsi:schemaLocation="http://www.springframework.org/schema/beans
  10. http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  11. http://www.springframework.org/schema/tx
  12. http://www.springframework.org/schema/tx/spring-tx.xsd
  13. http://www.springframework.org/schema/context
  14. http://www.springframework.org/schema/context/spring-context.xsd
  15. http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
  16. 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"
  17. xmlns:aop="http://www.springframework.org/schema/aop">
  18. <!--业务Beans, 使用注解方式配置-->
  19. <context:component-scan base-package="com.yihu.hos">
  20. </context:component-scan>
  21. <!--====================返回为null的时候转“”==========================-->
  22. <mvc:annotation-driven>
  23. <mvc:message-converters register-defaults="true">
  24. <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
  25. <property name="objectMapper">
  26. <bean class="com.fasterxml.jackson.databind.ObjectMapper">
  27. <property name="serializationInclusion">
  28. <value type="com.fasterxml.jackson.annotation.JsonInclude.Include">NON_NULL</value>
  29. </property>
  30. </bean>
  31. </property>
  32. </bean>
  33. </mvc:message-converters>
  34. </mvc:annotation-driven>
  35. <!--Hibernate 数据库配置-->
  36. <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
  37. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  38. <property name="url" value="jdbc:mysql://172.19.103.71:3306/esb?useUnicode=true&amp;characterEncoding=UTF-8"/>
  39. <property name="username" value="hos"/>
  40. <property name="password" value="hos"/>
  41. <property name="initialSize" value="1"/>
  42. <property name="maxTotal" value="100"/>
  43. <property name="maxIdle" value="50"/>
  44. <property name="minIdle" value="20"/>
  45. <property name="validationQuery" value="SELECT 1"/>
  46. <property name="testOnBorrow" value="true"/>
  47. <property name="removeAbandonedTimeout" value="55"/>
  48. </bean>
  49. <!--Hibernate 会话管理器配置-->
  50. <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  51. <property name="dataSource" ref="dataSource"/>
  52. <property name="packagesToScan">
  53. <list>
  54. <!-- 可以加多个包 -->
  55. <value>com.yihu.hos.standard.model</value>
  56. </list>
  57. </property>
  58. <property name="hibernateProperties">
  59. <value>
  60. hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
  61. hibernate.show_sql=false
  62. hibernate.format_sql=true
  63. </value>
  64. </property>
  65. <property name="mappingLocations">
  66. <list>
  67. <!-- <value>classpath:hbm/*.hbm.xml</value>-->
  68. <value>classpath:resource/*.hbm.xml</value>
  69. </list>
  70. </property>
  71. </bean>
  72. <!-- 将多个配置文件读取到容器中,交给Spring管理 -->
  73. <!--Hibernate 事务配置-->
  74. <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  75. <property name="sessionFactory" ref="sessionFactory"/>
  76. </bean>
  77. <tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>
  78. <!--文件上传支持-->
  79. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
  80. <!--国际化配置-->
  81. <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
  82. <description>Message Sources</description>
  83. <property name="basenames">
  84. <list>
  85. <value>text/message</value>
  86. </list>
  87. </property>
  88. <property name="defaultEncoding" value="UTF-8"/>
  89. </bean>
  90. <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
  91. <property name="cookieMaxAge" value="604800"/>
  92. <property name="defaultLocale" value="zh_CN"/>
  93. <property name="cookieName" value="Language"></property>
  94. </bean>
  95. <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
  96. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  97. <property name="dataSource" ref="dataSource"/>
  98. </bean>
  99. <!--Hibernate模版配置 -->
  100. <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
  101. <property name="sessionFactory" ref="sessionFactory"></property>
  102. </bean>
  103. <!--<bean id="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" scope="singleton">-->
  104. <!--<property name="dataSource" ref="dataSource"/>-->
  105. <!--<property name="configLocation" value="classpath:/config/quartz.properties" />-->
  106. <!--<property name="autoStartup" value="true"/>-->
  107. <!--</bean>-->
  108. </beans>