Files
SIPAIIS_WMS_JSSW/src/main/webapp/WEB-INF/spring-mybatis.xml

265 lines
13 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd" default-lazy-init="true">
<import resource="activiti.cfg.xml"/>
<import resource="spring-mybatis-scada.xml"/>
<!-- 自动扫描 -->
<context:component-scan base-package="com.sipai"/>
<!-- 引入配置文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:db.properties</value>
<value>classpath:redis.properties</value>
<value>classpath:minio.properties</value>
<value>classpath:mqtt.properties</value>
<value>classpath:modbus.properties</value>
<value>classpath:pythonModel.properties</value>
<value>classpath:work.properties</value>
<value>classpath:library.properties</value>
<value>classpath:thirdRequest.properties</value>
<value>classpath:xxl-job-executor.properties</value>
</list>
</property>
</bean>
<!-- minio配置类初始化 -->
<bean id="minioProp" class="com.sipai.tools.MinioProp">
<property name="endPoint" value="${minio.endPoint}"/>
<property name="accessKey" value="${minio.accessKey}"/>
<property name="secretKey" value="${minio.secretKey}"/>
</bean>
<!-- modbus配置类初始化 -->
<bean id="modbusProp" class="com.sipai.tools.ModbusProp">
<property name="url" value="${modbus.url}"/>
<property name="port" value="${modbus.port}"/>
</bean>
<!-- 第三方同步接口 -->
<bean id="thirdRequestProp" class="com.sipai.tools.ThirdRequestProp">
<property name="interfaces" value="${interfaces}"/>
<property name="boturl" value="${boturl}"/>
<property name="bottoken" value="${bottoken}"/>
</bean>
<!-- modbus配置类初始化 -->
<bean id="pythonModelProp" class="com.sipai.tools.PythonModelProp">
<property name="restart" value="${py.restart}"/>
<property name="person" value="${py.person}"/>
<property name="receiveData" value="${py.receiveData}"/>
</bean>
<!-- mqtt配置类初始化 -->
<bean id="mqtt" class="com.sipai.tools.Mqtt">
<property name="status" value="${mqtt.status}"/>
<property name="username" value="${mqtt.username}"/>
<property name="password" value="${mqtt.password}"/>
<property name="hostTcp" value="${mqtt.host_tcp}"/>
<property name="hostWeb" value="${mqtt.host_ws}"/>
</bean>
<!-- 工单类配置类初始化 -->
<bean id="work" class="com.sipai.tools.Work">
<property name="mainPlanAuto" value="${work.main_plan_auto}"/>
<property name="intactRate" value="${work.intact_rate}"/>
<property name="compete" value="${work.compete}"/>
</bean>
<!-- 各类库配置类初始化 -->
<bean id="library" class="com.sipai.tools.LibraryTool">
<property name="repairPart" value="${library.repair_part}"/>
<property name="mainPart" value="${library.main_part}"/>
<property name="overhaulPart" value="${library.overhaul_part}"/>
</bean>
<bean id="dataSourceMaster" class="com.alibaba.druid.pool.DruidDataSource" init-method="init"
destroy-method="close">
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="8"/>
<property name="minIdle" value="5"/>
<property name="maxActive" value="19"/>
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="30000"/>
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000"/>
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000"/>
<property name="testWhileIdle" value="true"/>
<!-- 这里建议配置为TRUE防止取到的连接不可用 -->
<property name="testOnBorrow" value="true"/>
<property name="testOnReturn" value="false"/>
<!-- 打开PSCache并且指定每个连接上PSCache的大小 -->
<property name="poolPreparedStatements" value="true"/>
<property name="maxPoolPreparedStatementPerConnectionSize"
value="20"/>
<!-- 这里配置提交方式默认就是TRUE可以不用配置 -->
<property name="defaultAutoCommit" value="true"/>
<!-- 验证连接有效与否的SQL不同的数据配置不同 -->
<property name="validationQuery" value="select 1 "/>
<!-- 开启Druid的监控统计功能,StatFilter可以和其他的Filter配置使用 -->
<property name="filters" value="stat,wall,log4j"/>
<!-- proxyFilters属性配置,通过bean的方式配置 -->
<property name="proxyFilters">
<list>
<ref bean="log-filter"/>
</list>
</property>
</bean>
<!-- 上面的druid的配置 -->
<bean id="log-filter" class="com.alibaba.druid.filter.logging.Log4j2Filter">
<!-- 所有连接相关的日志 -->
<property name="connectionLogEnabled" value="false"/>
<!-- 所有Statement相关的日志 -->
<property name="statementLogEnabled" value="false"/>
<!-- 是否显示结果集 -->
<property name="resultSetLogEnabled" value="true"/>
<!-- 是否显示SQL语句 -->
<property name="statementExecutableSqlLogEnable" value="true"/>
</bean>
<!-- <bean id="SCADA_HFCG" class="com.alibaba.druid.pool.DruidDataSource" init-method="init"-->
<!-- destroy-method="close">-->
<!-- <property name="driverClassName" value="${driver}"/>-->
<!-- <property name="url" value="${scada-url}"/>-->
<!-- <property name="username" value="${scada-username}"/>-->
<!-- <property name="password" value="${scada-password}"/>-->
<!-- &lt;!&ndash; 配置初始化大小、最小、最大 &ndash;&gt;-->
<!-- <property name="initialSize" value="8"/>-->
<!-- <property name="minIdle" value="5"/>-->
<!-- <property name="maxActive" value="19"/>-->
<!-- &lt;!&ndash; 配置获取连接等待超时的时间 &ndash;&gt;-->
<!-- <property name="maxWait" value="30000"/>-->
<!-- &lt;!&ndash; 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 &ndash;&gt;-->
<!-- <property name="timeBetweenEvictionRunsMillis" value="60000"/>-->
<!-- &lt;!&ndash; 配置一个连接在池中最小生存的时间,单位是毫秒 &ndash;&gt;-->
<!-- <property name="minEvictableIdleTimeMillis" value="300000"/>-->
<!-- <property name="testWhileIdle" value="true"/>-->
<!-- &lt;!&ndash; 这里建议配置为TRUE防止取到的连接不可用 &ndash;&gt;-->
<!-- <property name="testOnBorrow" value="true"/>-->
<!-- <property name="testOnReturn" value="false"/>-->
<!-- &lt;!&ndash; 打开PSCache并且指定每个连接上PSCache的大小 &ndash;&gt;-->
<!-- <property name="poolPreparedStatements" value="true"/>-->
<!-- <property name="maxPoolPreparedStatementPerConnectionSize"-->
<!-- value="20"/>-->
<!-- </bean>-->
<bean id="dataSource" class="com.sipai.tools.DynamicDataSource">
<property name="defaultTargetDataSource" ref="dataSourceMaster"/>
<property name="targetDataSources">
<map key-type="com.sipai.tools.DataSources">
<entry key="MASTER" value-ref="dataSourceMaster"/>
<!-- <entry key="SCADA_HFCG" value-ref="SCADA_HFCG"/>-->
<entry key="SCADA_0533JS" value-ref="SCADA_0533JS"/>
<!-- 这里还可以加多个dataSource -->
</map>
</property>
</bean>
<!-- spring和MyBatis整合 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- <property name="configLocation" value="/WEB-INF/mybatis-config.xml"></property> -->
<!-- 自动扫描mapping.xml文件 -->
<property name="mapperLocations">
<array>
<value>classpath*:com/sipai/mapper/**/*.xml</value>
</array>
</property>
<!-- 翻页功能 -->
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageHelper">
<property name="properties">
<value>
dialect=sqlserver
reasonable=true
</value>
</property>
</bean>
</array>
</property>
</bean>
<!-- 获取sqlSession, 用于commDao的实现-->
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.sipai.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
<!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- enable transaction annotation support -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- 需要将流程引擎的事务托管给spring统一管理 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="start*" propagation="REQUIRED"/>
<tx:method name="execute*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="remove*" propagation="REQUIRED"/>
<tx:method name="assign*" propagation="REQUIRED"/>
<tx:method name="create*" propagation="REQUIRED"/>
<tx:method name="complete*" propagation="REQUIRED"/>
<tx:method name="finish*" propagation="REQUIRED"/>
<tx:method name="terminate*" propagation="REQUIRED"/>
<tx:method name="take*" propagation="REQUIRED"/>
<tx:method name="deploy*" propagation="REQUIRED"/>
<tx:method name="undeploy*" propagation="REQUIRED"/>
<tx:method name="redeploy*" propagation="REQUIRED"/>
<tx:method name="get*" propagation="REQUIRED" read-only="true"/>
<tx:method name="find*" propagation="REQUIRED" read-only="true"/>
<tx:method name="query*" propagation="REQUIRED" read-only="true"/>
<tx:method name="search*" propagation="REQUIRED" read-only="true"/>
<tx:method name="is*" propagation="REQUIRED" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<bean id="dataSourceScadaBean" class="com.sipai.tools.DataSourceInterceptor"/>
<aop:config>
<aop:pointcut id="transactionPointcut" expression="execution(public * com.sipai.service.*.*(..))"/>
<aop:pointcut id="dataSourceScadaPointcut" expression="execution(public * com.sipai.service.scada.*.*(..)))"/>
<aop:advisor pointcut-ref="transactionPointcut"
advice-ref="txAdvice"/>
<aop:aspect ref="dataSourceScadaBean" order="0">
<aop:before method="before" pointcut-ref="dataSourceScadaPointcut"></aop:before>
<aop:after method="after" pointcut-ref="dataSourceScadaPointcut"></aop:after>
</aop:aspect>
</aop:config>
<!-- 开启aop注解方式 -->
<aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>
</beans>