• spring-common.xml


    <?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:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd    
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
        default-lazy-init="true">
     
    
        <!-- 自动搜索@Component,@Service,@Repository等标注的类 不搜索@Controller的类 -->
        <!-- 自动扫描组件,这里要把web下面的 controller去除,它们是在spring3-servlet.xml中配置的,如果不去除会影响事务 -->
        <context:component-scan base-package="cn.edu.hbcf,com.ruijie"
            annotation-config="true">
            <context:exclude-filter type="annotation"
                expression="org.springframework.stereotype.Controller" />
        </context:component-scan>
        
        <context:component-scan base-package="cn.edu.hbcf,com.ruijie"
            annotation-config="true">
            <context:include-filter type="annotation"
                expression="org.springframework.stereotype.Service" />
        </context:component-scan>
    
        <!-- enable autowire 允许自动装配 -->
        <context:annotation-config />
    
        
        <!-- service层的属性和配置文件读入,多个用逗号隔开 -->
        <!-- controller层的属性和配置文件读入,多个用逗号隔开 -->
        <context:property-placeholder
            location="classpath:/jdbc.properties" />
        <!-- 用于持有ApplicationContext,可以使用SpringContextHolder.getBean('xxx')的静态方法得到spring bean对象 -->
        <bean class="cn.edu.hbcf.common.springmvc.SpringContextHolder"
            lazy-init="false" />
            
        <!-- ######################################################privilege数据库#################################################################### -->
        <!-- 数据连接事务 -->    
        <bean id="privilegeTransactionManager"
            class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="privilegeDataSource" />
            <qualifier></qualifier>
        </bean>
        <bean id="privilegeSqlSessionFactory"
            class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="privilegeDataSource" />
            <!-- mybatis配置文件所在位置 -->
            <property name="configLocation"
                value="classpath:/sqlMap/mybatis-privilege.xml" />
            <!-- 别名所在包 -->
            <property name="typeAliasesPackage" value="cn.edu.hbcf"/>
        </bean>
        <!-- 从base 包中搜索所有下面所有 interface,并将其注册到 Spring Bean容器中,
            其注册的class bean是MapperFactoryBean -->
        <bean id="privilegeScannerConfigurer"
            class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="sqlSessionFactory" ref="privilegeSqlSessionFactory"/>
            <property name="basePackage" value="cn.edu.hbcf.privilege.dao,cn.edu.hbcf.notice.dao">
            </property>
        </bean>
        
                <!-- 连接事务的注解配置 -->
        <tx:annotation-driven
            transaction-manager="privilegeTransactionManager" />
        
        <!-- ######################################################framework数据库#################################################################### -->
        <!-- 数据连接事务 -->    
        <bean id="frameworkTransactionManager"
            class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="privilegeDataSource" />
            <qualifier></qualifier>
        </bean>
        <bean id="frameworkSqlSessionFactory"
            class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="privilegeDataSource" />
            <!-- mybatis配置文件所在位置 -->
            <property name="configLocation"
                value="classpath:/sqlMap/mybatis-framework.xml" />
            <!-- 别名所在包 -->
            <property name="typeAliasesPackage" value="cn.edu.hbcf"/>
        </bean>
        <!-- 从base 包中搜索所有下面所有 interface,并将其注册到 Spring Bean容器中,
            其注册的class bean是MapperFactoryBean -->
        <bean id="frameworkScannerConfigurer"
            class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="sqlSessionFactory" ref="frameworkSqlSessionFactory"/>
            <property name="basePackage" value="cn.edu.hbcf.framework.dao">
            </property>
        </bean>
        
        <!-- 连接事务的注解配置 -->
        <tx:annotation-driven
            transaction-manager="frameworkTransactionManager" />
            
    
          <!-- ######################################################ucenter数据库#################################################################### -->
        <!-- 数据连接事务 -->
        <bean id="ucenterTransactionManager"
            class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="ucenterDataSource" />
        </bean>
        <bean id="ucenterSqlSessionFactory"
            class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="ucenterDataSource" />
            <!-- mybatis配置文件所在位置 -->
            <property name="configLocation"
                value="classpath:/sqlMap/mybatis-ucenter.xml" />
            <!-- 别名所在包 -->
            <property name="typeAliasesPackage" value="cn.edu.hbcf" />
        </bean>
        <!-- 从base 包中搜索所有下面所有 interface,并将其注册到 Spring Bean容器中,
            其注册的class bean是MapperFactoryBean-->
        <bean id="ucenterScannerConfigurer"
            class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="sqlSessionFactory" ref="ucenterSqlSessionFactory"/>
            <property name="basePackage" value="cn.edu.hbcf.privilege.cas.dao"></property>
        </bean>
        <bean id="infoTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="infoDataSource"/>
        </bean>
    
        
    </beans>
  • 相关阅读:
    utf-8编码汉字转换成对于的16进制 10进制对于的值
    CentOS 6和CentOS 7命令区别
    dedecms二次开发帮助文档地址
    DEDE整站动态化或整站静态化设置方法
    dede数据库表结构和dedecms数据库字段说明
    c++如何编写线程安全的DLL
    Socket中常见的几个转换函数(htonl,htons,ntohl,ntohs,inet_addr,inet_ntoa)
    Winsock 示例
    命名管道的使用方式:消息模式/字节模式
    命名管道-简单的例子
  • 原文地址:https://www.cnblogs.com/zrui-xyu/p/4942958.html
Copyright © 2020-2023  润新知