初始化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
4.9 KiB

  1. <beans xmlns="http://www.springframework.org/schema/beans"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns:context="http://www.springframework.org/schema/context"
  4. xmlns:aop="http://www.springframework.org/schema/aop"
  5. xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  7. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
  8. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
  9. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
  10. http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
  11. <aop:config proxy-target-class="true"/>
  12. <context:annotation-config/>
  13. <context:component-scan base-package="com.sie.demo.comm.model.dao,com.sie.demo.comm.model.inter.server,cn.hutool.extra.spring"/>
  14. <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  15. <property name="locations">
  16. <list>
  17. <value>classpath:com/sie/demo/comm/config/db_jdbc.properties</value>
  18. </list>
  19. </property>
  20. </bean>
  21. <bean id="dataSource" destroy-method="close" class="com.sie.iot.common.dbcp.BasicDataSourceDecrypt">
  22. <property name="driverClassName" value="${properties.jdbc.driverClassName}"/>
  23. <property name="url" value="${properties.jdbc.url}"/>
  24. <property name="username" value="${properties.jdbc.username}"/>
  25. <property name="password" value="${properties.jdbc.password}"/>
  26. <property name="validationQuery" value="${properties.jdbc.validationQuery}"/>
  27. <property name="initialSize" value="${properties.jdbc.initialSize}"/>
  28. <property name="maxActive" value="${properties.jdbc.maxActive}"/>
  29. <property name="maxIdle" value="${properties.jdbc.maxIdle}"/>
  30. <property name="minIdle" value="${properties.jdbc.minIdle}"/>
  31. </bean>
  32. <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
  33. <property name="dataSource" ref="dataSource"/>
  34. <property name="packagesToScan">
  35. <list>
  36. <value>com.sie.demo.comm.model.entities</value>
  37. </list>
  38. </property>
  39. <property name="hibernateProperties">
  40. <props>
  41. <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
  42. <prop key="hibernate.show_sql">true</prop>
  43. <!--<prop key="hibernate.hbm2ddl.auto">update</prop>-->
  44. <prop key="javax.persistence.validation.mode">none</prop>
  45. </props>
  46. </property>
  47. </bean>
  48. <bean id="hibernateTemplete" class="org.springframework.orm.hibernate5.HibernateTemplate">
  49. <property name="sessionFactory" ref="sessionFactory"></property>
  50. </bean>
  51. <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
  52. <property name="sessionFactory" ref="sessionFactory"></property>
  53. </bean>
  54. <!-- 配置事务的传播特性 -->
  55. <tx:advice id="txAdvice" transaction-manager="transactionManager">
  56. <tx:attributes>
  57. <tx:method name="insert*" propagation="REQUIRED" rollback-for="Exception" read-only="false"/>
  58. <tx:method name="save*" propagation="REQUIRED" rollback-for="Exception" read-only="false"/>
  59. <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception" read-only="false"/>
  60. <tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception" read-only="false"/>
  61. <tx:method name="find*" read-only="true"/>
  62. </tx:attributes>
  63. </tx:advice>
  64. <!-- 那些类的哪些方法参与事务 -->
  65. <aop:config><!--|| execution(* com.sie.saaf.*.model.dao.readonly.*.*(..))-->
  66. <aop:pointcut id="businessService" expression="execution(* com.sie.demo.comm.model.inter.server.*.*(..))
  67. || execution(* com.sie.iot.common.model.inter.server.*.*(..))
  68. || execution(* com.sie.iot.file.model.inter.server.*.*(..))"/>
  69. <aop:advisor advice-ref="txAdvice" pointcut-ref="businessService" order="0"/>
  70. </aop:config>
  71. <bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
  72. <property name="hostName" value="${spring.redis.host}"></property>
  73. <property name="port" value="${spring.redis.port}"/>
  74. <property name="password" value="${spring.redis.password}"></property>
  75. </bean>
  76. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
  77. <property name="connectionFactory" ref="redisConnectionFactory"></property>
  78. </bean>
  79. </beans>