applicationContext.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.ehr">
  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. <!--
  39. <property name="url"
  40. value="jdbc:mysql://172.19.103.50:3306/healtharchive?useUnicode=true&amp;characterEncoding=UTF-8"/>
  41. <property name="username" value="fujian"/>
  42. <property name="password" value="fujian"/>
  43. -->
  44. <property name="url"
  45. value="jdbc:mysql://172.19.103.71:3306/esb?useUnicode=true&amp;characterEncoding=UTF-8"/>
  46. <property name="username" value="hos"/>
  47. <property name="password" value="hos"/>
  48. <property name="initialSize" value="1"/>
  49. <property name="maxTotal" value="100"/>
  50. <property name="maxIdle" value="50"/>
  51. <property name="minIdle" value="20"/>
  52. <property name="validationQuery" value="SELECT 1"/>
  53. <property name="testOnBorrow" value="true"/>
  54. <property name="removeAbandonedTimeout" value="55"/>
  55. </bean>
  56. <!--Hibernate 会话管理器配置-->
  57. <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  58. <property name="dataSource" ref="dataSource"/>
  59. <property name="packagesToScan">
  60. <list>
  61. <!-- 可以加多个包 -->
  62. <value>com.yihu.ehr.standard.model</value>
  63. </list>
  64. </property>
  65. <property name="hibernateProperties">
  66. <value>
  67. hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
  68. hibernate.show_sql=true
  69. hibernate.format_sql=true
  70. </value>
  71. </property>
  72. <property name="mappingLocations">
  73. <list>
  74. <!-- <value>classpath:hbm/*.hbm.xml</value>-->
  75. <value>classpath:hbm/resource/*.hbm.xml</value>
  76. </list>
  77. </property>
  78. </bean>
  79. <!-- 将多个配置文件读取到容器中,交给Spring管理 -->
  80. <!--Hibernate 事务配置-->
  81. <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  82. <property name="sessionFactory" ref="sessionFactory"/>
  83. </bean>
  84. <tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>
  85. <aop:aspectj-autoproxy/>
  86. <!--Redis 连接池配置-->
  87. <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
  88. <property name="maxTotal" value="15"/>
  89. <property name="maxIdle" value="10"/>
  90. <property name="minIdle" value="5"/>
  91. </bean>
  92. <!--Redis 数据库配置-->
  93. <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
  94. <!--property name="hostName" value="172.17.110.68" note="use this element when deploy on tomcat in real"/-->
  95. <property name="hostName" value="192.168.1.220"/>
  96. <property name="port" value="6379"/>
  97. <property name="poolConfig" ref="poolConfig"/>
  98. </bean>
  99. <!--Redis 会话管理器配置-->
  100. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
  101. <property name="connectionFactory" ref="jedisConnectionFactory"/>
  102. </bean>
  103. <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
  104. <property name="customEditors">
  105. <map>
  106. <entry key="com.yihu.ehr.framework.constrant.JobType"
  107. value="com.yihu.ehr.framework.util.web.JobTypeConverter"/>
  108. </map>
  109. </property>
  110. </bean>
  111. <!--文件上传支持-->
  112. <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
  113. <!--国际化配置-->
  114. <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
  115. <description>Message Sources</description>
  116. <property name="basenames">
  117. <list>
  118. <value>text/message</value>
  119. </list>
  120. </property>
  121. <property name="defaultEncoding" value="UTF-8"/>
  122. </bean>
  123. <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
  124. <property name="cookieMaxAge" value="604800"/>
  125. <property name="defaultLocale" value="zh_CN"/>
  126. <property name="cookieName" value="Language"></property>
  127. </bean>
  128. <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
  129. <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  130. <property name="dataSource" ref="dataSource"/>
  131. </bean>
  132. <!--Hibernate模版配置 -->
  133. <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
  134. <property name="sessionFactory" ref="sessionFactory"></property>
  135. </bean>
  136. </beans>