applicationContext

命名空间:

引入命名空间,这样可以在代码中使用annotation

xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<!-- 引入注解 -->

<context:annotation-config/>

<!-- 注册并将bean交给IOC容器控制,但是不注册controller类-->

<context:component-scan base-package:"com.wtw.*">

  <context:exclude-filter: type:"annotation" expression="org.springframework.stereotype.Controller"

</context:compnent-scan>

<!-- 导入数据库连接配置文件-->

<context:property-placeholder location="classpath:jdbc.properties"/>

<!-- 数据库连接池-->

<bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destory-method="close">

  <property name="driverClassName" value="${driverClass}"/>

  <property name="url" value="${jdbcurl}"/>

  <property name="username" value="${username}"/>

  <property name="password" value="${password}"/>

</bean>

<!-- 配置jdbcTemplate -->

<bean name="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">

  <property name="dataSource" ref="dataSource"/>

</bean>

<!-- 采用注解的方式配置事务-->

<bean name="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

  <property name="dataSource" ref="dataSource"/>

</bean>

<tx:annotation-driven transaction-manager="txManager"/>

最新文章

  1. ASP.NET Core 中文文档 第三章 原理(10)依赖注入
  2. 深入学习jQuery选择器系列第一篇——基础选择器和层级选择器
  3. MyBatis学习总结(二)——使用MyBatis对表执行CRUD操作(转载)
  4. ActionScript 3.0 自写类整理笔记(十三)——Random类
  5. Android基于mAppWidget实现手绘地图(十四)–在一个应用中使用多个地图
  6. 【Android】用HandlerThread模拟AsyncTask功能(ThreadTask)
  7. Windows Phone App Studio 无码开发手机应用
  8. linux网络编程_1
  9. 各种边框样式。。本以为border不是这么用的。
  10. poj 1087.A Plug for UNIX (最大流)
  11. 什么是Ajax? (转载于疯狂客的BLOG)
  12. 如何使用TestFlight进行App构建版本测试(转)
  13. HttpClient使用详解
  14. app.config 配置多项 配置集合 自定义配置(4) 自动增加配置项到配置文件的两种方法
  15. [Codeforces 864B]Polycarp and Letters
  16. ubuntu16.04安装eclipse后启动栏图标为问号
  17. kubernetes微服务部署
  18. 图解HTTP / HTTPS
  19. MIT molecular Biology 笔记11 位点特异性重组 和 DNA转座
  20. 【BZOJ-3218】a+b Problem 最小割 + 可持久化线段树

热门文章

  1. NOIP2016报零记
  2. JAVA的单例模式与延时加载
  3. 【转载】关于OpenGL的图形流水线
  4. 初遇 dotcloud
  5. 查询expression的小工具
  6. linux云服务器mysql ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
  7. Controller
  8. ivy 配置 maven代理
  9. mongoDB之Pipeline Aggregation Stages
  10. Java在Web项目中读取properties文件