applicationContext.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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"
  17. >
  18. <!--业务Beans, 使用注解方式配置-->
  19. <context:component-scan base-package="com.yihu">
  20. <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
  21. </context:component-scan>
  22. <!--====================返回为null的时候转“”==========================-->
  23. <mvc:annotation-driven>
  24. <mvc:message-converters register-defaults="true">
  25. <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
  26. <property name="objectMapper">
  27. <bean class="com.fasterxml.jackson.databind.ObjectMapper">
  28. <property name="serializationInclusion">
  29. <value type="com.fasterxml.jackson.annotation.JsonInclude.Include">NON_NULL</value>
  30. </property>
  31. </bean>
  32. </property>
  33. </bean>
  34. </mvc:message-converters>
  35. </mvc:annotation-driven>
  36. <!--Hibernate 数据库配置-->
  37. <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
  38. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  39. <!--
  40. <property name="url"
  41. value="jdbc:mysql://172.19.103.50:3306/healtharchive?useUnicode=true&amp;characterEncoding=UTF-8"/>
  42. <property name="username" value="fujian"/>
  43. <property name="password" value="fujian"/>
  44. -->
  45. <property name="url"
  46. value="jdbc:mysql://192.168.1.220:3306/hos2_resource?useUnicode=true&amp;characterEncoding=UTF-8"/>
  47. <property name="username" value="hos2"/>
  48. <property name="password" value="hos2"/>
  49. <property name="initialSize" value="1"/>
  50. <property name="maxTotal" value="100"/>
  51. <property name="maxIdle" value="50"/>
  52. <property name="minIdle" value="20"/>
  53. <property name="validationQuery" value="SELECT 1"/>
  54. <property name="testOnBorrow" value="true"/>
  55. <property name="removeAbandonedTimeout" value="55"/>
  56. </bean>
  57. <!--Hibernate 会话管理器配置-->
  58. <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  59. <property name="dataSource" ref="dataSource"/>
  60. <property name="hibernateProperties">
  61. <value>
  62. hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
  63. hibernate.show_sql=true
  64. hibernate.format_sql=true
  65. </value>
  66. </property>
  67. <property name="mappingLocations">
  68. <list>
  69. <!-- <value>classpath:hbm/*.hbm.xml</value>-->
  70. <value>classpath:hbm/resource/*.hbm.xml</value>
  71. </list>
  72. </property>
  73. </bean>
  74. <!-- 将多个配置文件读取到容器中,交给Spring管理 -->
  75. <util:properties id="propertyConfigurer" location="classpath:/resource.properties"/>
  76. <!--Hibernate 事务配置-->
  77. <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  78. <property name="sessionFactory" ref="sessionFactory"/>
  79. </bean>
  80. <tx:annotation-driven transaction-manager="txManager"/>
  81. <!--Redis 连接池配置-->
  82. <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
  83. <property name="maxTotal" value="15"/>
  84. <property name="maxIdle" value="10"/>
  85. <property name="minIdle" value="5"/>
  86. </bean>
  87. <!--Redis 数据库配置-->
  88. <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
  89. <!--property name="hostName" value="172.17.110.68" note="use this element when deploy on tomcat in real"/-->
  90. <property name="hostName" value="192.168.1.220"/>
  91. <property name="port" value="6379"/>
  92. <property name="poolConfig" ref="poolConfig"/>
  93. </bean>
  94. <!--Redis 会话管理器配置-->
  95. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
  96. <property name="connectionFactory" ref="jedisConnectionFactory"/>
  97. </bean>
  98. <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
  99. <property name="customEditors">
  100. <map>
  101. <entry key="com.yihu.ehr.framework.constrant.JobType"
  102. value="com.yihu.ehr.framework.util.web.JobTypeConverter"/>
  103. </map>
  104. </property>
  105. </bean>
  106. <!--文件上传支持-->
  107. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
  108. <!--国际化配置-->
  109. <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
  110. <description>Message Sources</description>
  111. <property name="basenames">
  112. <list>
  113. <value>text/message</value>
  114. </list>
  115. </property>
  116. <property name="defaultEncoding" value="UTF-8"/>
  117. </bean>
  118. <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
  119. <property name="cookieMaxAge" value="604800"/>
  120. <property name="defaultLocale" value="zh_CN"/>
  121. <property name="cookieName" value="Language"></property>
  122. </bean>
  123. <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
  124. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  125. <property name="dataSource" ref="dataSource"/>
  126. </bean>
  127. <!--Hibernate模版配置 -->
  128. <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
  129. <property name="sessionFactory" ref="sessionFactory"></property>
  130. </bean>
  131. </beans>