文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Spring+JDBC组合开发配置数据源有两..

Spring+JDBC组合开发配置数据源有两..

时间:2010-10-14  来源:huzhiyang2009

  1. Spring+JDBC组合开发配置数据源有两种方式:
  2.  
  3.  
  4. 1.基于XML
  5.  
  6.  
  7. 2.基于注解
  8.  
  9.  
  10. 首先我们看看基于XML的配置:
  11.  
  12.  
  13.  
  14. 步骤:
  15.  
  16. 1.首先导入我们数据源依赖的jar包,如下图
  17.  
  18.  
  19.  
  20. 2.写beans.xml配置文件,配置事务时,需要在xml配置文件中引入用于声明事务的tx命名空间
  21.  
  22.  
  23.  
  24. 比以前的配置文件多了
  25.  
  26.        xmlns:tx="http://www.springframework.org/schema/tx"
  27.        http://www.springframework.org/schema/tx
  28.            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
  29.  
  30.  
  31.  
  32. Java代码
  33. <?xml version="1.0" encoding="UTF-8"?>   
  34. <beans xmlns="http://www.springframework.org/schema/beans"  
  35.              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  36.        xmlns:aop="http://www.springframework.org/schema/aop"  
  37.        xmlns:context="http://www.springframework.org/schema/context"  
  38.        xmlns:tx="http://www.springframework.org/schema/tx"  
  39.        xsi:schemaLocation="http://www.springframework.org/schema/beans   
  40.            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
  41.            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd   
  42.            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd   
  43.            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> 

来自

相关阅读 更多 +
排行榜 更多 +
泡龙大闯关安卓版

泡龙大闯关安卓版

冒险解谜 下载
割草派对安卓版

割草派对安卓版

飞行射击 下载
堡垒攻防战安卓版

堡垒攻防战安卓版

飞行射击 下载