Spring和Ibatis整合的项目,详细篇
来源:互联网 发布:疯狂联盟龙数据 编辑:程序博客网 时间:2024/06/05 15:10
用到的配置文件,基本如下:
SqlMapConfig.xml,Bean.xml
Spring.xml
web.xml
以上为所使用的xml文件,当然还可以在xml里载入外部的properties文件了
既然和Spring整合了,Ibatis的SqlMapConfig.xml文件中仅有的内容就是加载Bean.xml了,所有的关于数据库的东西全部交给Spring.xml了
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans><bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><list><value>classpath:db.properties</value></list></property></bean><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close"><property name="driverClassName" value="${driver}" /><property name="url" value="${url}" /><property name="username" value="${username}" /><property name="password" value="${password}" /><property name="maxActive" value="${maxActive}" /><property name="maxIdle" value="${maxIdle}" /><property name="maxWait" value="${maxWait}" /><property name="defaultAutoCommit" value="${defaultAutoCommit}" /><property name="logAbandoned" value="${logAbandoned}"></property></bean><!-- SqlMap setup for iBATIS Database Layer --><bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"><property name="configLocation"><value>classpath:SqlMapConfig.xml</value></property><property name="dataSource" ref="dataSource" /></bean><bean id="mail" class="cn.cisco.com.mail.Mail" /><bean id="monDao" class="cn.cisco.com.dao.impl.MonDAOImpl"><property name="sqlMapClient" ref="sqlMapClient" /><property name="mail" ref="mail" /></bean><bean id="monService" class="cn.cisco.com.service.impl.MonServiceImpl"><property name="monDao" ref="monDao" /><property name="transactionManager"><ref bean="transactionManager" /></property></bean><bean id="monitor" class="cn.cisco.com.main.Monitor"><property name="monService" ref="monService" /></bean><bean id="startListener" class="cn.cisco.com.main.StartListener"><property name="monitor" ref="monitor" /></bean><bean id="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource"><ref bean="dataSource" /></property></bean></beans>
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE sqlMapConfigPUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN""http://www.ibatis.com/dtd/sql-map-config-2.dtd"><sqlMapConfig><sqlMap resource="cn/cisco/com/bean/monitor.xml" /></sqlMapConfig>
Bean.xml文件就是全部的sql语句了,不多说了
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>monitor</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:Spring.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app>
OK了
- Spring和Ibatis整合的项目,详细篇
- ibatis和Spring整合的详细例子
- ibatis和Spring整合的详细例子
- ibatis和Spring整合的详细例子
- iBatis和Spring的整合
- ibatis和spring的整合
- spring和ibatis整合
- ibatis和spring和truts2的整合
- Spring和iBatis整合的例子
- Spring和iBatis整合的例子
- Spring和iBatis整合的方法
- Spring和Hibernate与Spring和Ibatis整合的差异
- ibatis和Spring整合实例
- Spring和Ibatis框架整合
- spring框架整合ibatis的项目实例代码
- spring框架整合ibatis的项目实例代码
- spring框架整合ibatis的项目实例代码
- spring框架整合ibatis的项目实例代码
- RegisterClientScriptBlock 与 RegisterStartupScript 的区别
- 读取proc文件之seq_file
- 全新web开发框架
- 逆流而上,全面开花------解读联想财报给pc产业带来的惊喜
- 如果爱,请深爱:10大iOS开发者最喜爱的类库
- Spring和Ibatis整合的项目,详细篇
- 函数将字符串中的字符'*'移到串的前部分
- java目录
- 没有找到MSVCR100.dll解决方法
- 北京理工大学人工智能第三次作业
- 我在阿里云的日子里,购买阿里云服务
- 下学习使用Teechart8记录 一 安装和熟悉teechart8
- 基于全硬件TCP/IP的产品应用实例
- 平台调用P-INVOKE(三)--(封送结构体)