SpringMVC环境搭建 配置文件_2
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"/>
最新文章
- ASP.NET Core 中文文档 第三章 原理(10)依赖注入
- 深入学习jQuery选择器系列第一篇——基础选择器和层级选择器
- MyBatis学习总结(二)——使用MyBatis对表执行CRUD操作(转载)
- ActionScript 3.0 自写类整理笔记(十三)——Random类
- Android基于mAppWidget实现手绘地图(十四)–在一个应用中使用多个地图
- 【Android】用HandlerThread模拟AsyncTask功能(ThreadTask)
- Windows Phone App Studio 无码开发手机应用
- linux网络编程_1
- 各种边框样式。。本以为border不是这么用的。
- poj 1087.A Plug for UNIX (最大流)
- 什么是Ajax? (转载于疯狂客的BLOG)
- 如何使用TestFlight进行App构建版本测试(转)
- HttpClient使用详解
- app.config 配置多项 配置集合 自定义配置(4) 自动增加配置项到配置文件的两种方法
- [Codeforces 864B]Polycarp and Letters
- ubuntu16.04安装eclipse后启动栏图标为问号
- kubernetes微服务部署
- 图解HTTP / HTTPS
- MIT molecular Biology 笔记11 位点特异性重组 和 DNA转座
- 【BZOJ-3218】a+b Problem 最小割 + 可持久化线段树
热门文章
- NOIP2016报零记
- JAVA的单例模式与延时加载
- 【转载】关于OpenGL的图形流水线
- 初遇 dotcloud
- 查询expression的小工具
- linux云服务器mysql ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
- Controller
- ivy 配置 maven代理
- mongoDB之Pipeline Aggregation Stages
- Java在Web项目中读取properties文件