当前位置: 首页 > article >正文

spring-context.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:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"xmlns:task="http://www.springframework.org/schema/cache"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"><!-- 1.注解扫描器 包掃描  --><context:component-scan base-package="com.chaiyi"><!--排除Controller注解   不扫描Controller注解--><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan><!--2.指定外部属性文件的位置/引入properties文件 --><context:property-placeholder location="classpath:jdbc.properties"/><!--3. 使用jdbc数据源 连接池 --><bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><property name="driverClassName" value="${jdbc.driver}"></property><property name="url" value="${jdbc.url}"></property><property name="password" value="${jdbc.password}"></property><property name="username" value="${jdbc.username}"></property></bean><!--4.配置mybatis sqlsessionFactory --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><!--注入数据源--><property name="dataSource" ref="dataSource"></property><!--关联mybatis配置文件--><property name="configLocation" value="classpath:mybatis.xml"></property><property name="typeAliasesPackage" value="com.chaiyi.entity"></property><!--将mpper.xml的配置文件放在resources中的mappers里--><property name="mapperLocations" value="classpath:mapper/*.xml"></property><!--<property name="plugins"><array><bean class="com.github.pagehelper.PageInterceptor"><property name="properties"   value="mysql"></property>  鏈接mysql數據庫</bean></array></property> --></bean><!--5.配置jdbc事务管理器 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"></property></bean><!--事务模板 编程式事务 --><bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate"><property name="transactionManager" ref="transactionManager"></property></bean><!-- 声明式事务  基于注解(事务注解驱动) --><tx:annotation-driven transaction-manager="transactionManager"/><!--定时任务注解驱动--><!--	<task:annotation-driven></task:annotation-driven>--><!--6.配置事务 transaction-manager:表示关联的事务管理器是谁 声明式 基于aop --><tx:advice transaction-manager="transactionManager" id="txa"><!--事务属性配置--><tx:attributes><!-- find select get开头的方法为只读事务,用来提高数据库,用来提高数据库的性能所有添加修改删除操作不能以下列字符串开头--><tx:method name="find*" read-only="true"/><tx:method name="select*" read-only="true"/><tx:method name="get*" read-only="true"/><tx:method name="load*" read-only="true"/><tx:method name="list*" read-only="true"/><tx:method name="login*" read-only="true"/><!--其他的方法为默认事务--><tx:method name="*" isolation="DEFAULT" propagation="REQUIRED"/><!--    <tx:method name="find*"  read-only="true"/> --></tx:attributes></tx:advice><!--7.配置aop--><aop:config><!--配置切点表达式  tx(pointcut),txa(txAdvice)--><aop:pointcut expression="execution(* com.chaiyi.service.Impl.*.*(..))" id="tx"/><!--关联事务--><aop:advisor advice-ref="txa" pointcut-ref="tx"/></aop:config><!-- aop 切面注解 --><aop:aspectj-autoproxy></aop:aspectj-autoproxy><!--8.扫描mapper/dao接口掃描  --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><!--basePackage:mapper接口所在的包--><property name="basePackage" value="com.chaiyi.dao"></property></bean><!--9.引入spring-redis2.xml文件--><import resource="classpath:spring-redis.xml"></import><!--10.引入生产者spring-kafka-producer.xml文件--><import resource="classpath:spring-kafka-producer.xml"></import><!--11.引入消费者spring-kafka-consumer.xml文件--><import resource="classpath:spring-kafka-consumer.xml"></import><!--9.引入spring-es.xml文件--><import resource="classpath:spring-es.xml"></import>
</beans>

http://www.lryc.cn/news/2413715.html

相关文章:

  • 光交常用配置命令
  • 教你让XP等32位操作系统支持4G以上大内存,并且不出错
  • discuz! x2.5 代码执行流程浅析
  • ElasticSearch提供的bulk update性能对比
  • 12款免费网络硬盘
  • 评测一款php淘宝客系统,有商家报名和试用等功能
  • 开源源代码收集下载网站汇总
  • OGNL表达式和EL表达式
  • 后端开发——日志篇
  • XP完美模拟Vista全攻略
  • 手持电视cmmb网站
  • 使用wxWidgets进行跨平台的C++开发
  • Boilsoft Video Joiner(视频无损拼接)V9.1.3开心版 全网独一
  • 我的第一个VB程序
  • 编程常用工具
  • Spark SQL 初探: 使用大数据分析2000万数据
  • 安装程序不能验证 Update.inf 文件的完整性 之解决办法
  • 10分钟带你搭建属于自己的博客
  • 如何在谷歌地图(google maps)中获取经纬度
  • 基于DDD的微服务设计和开发实战
  • UILite——C++类库(XLib非界面功能库+UI和DirectUI库)简介
  • Linux操作系统介绍
  • 介绍个京阿尼的旧作
  • matlab水力学工具箱,水工设计工具箱免费版
  • 跨页传送-PreviousPage
  • 安卓应用《撕掉她的衣服》简化版
  • 新手唱歌从入门到精通,经典唱歌教程系列合集
  • 木马病毒表现手机中病毒/木马病毒对手机有用吗-手把手教白帽子自学
  • 解决笔记本电脑开机密码遗忘的几种方案,帮你轻松解除
  • 探索未来编程的新纪元:Eve语言