Spring 3.0.5+MyBatis3.0.4整合例子
考虑到MyBatis注解方式比较麻烦,可能都还没有xml来的方便,易读.所以就没有加上去.如有兴趣,自行参考http://panyongzheng.iteye.com/blog/1604067
if exists (select 1
from sysobjects
where id = object_id('Users')
and type = 'U')
drop table Users
go
/*==============================================================*/
/* Table: Users */
/*==============================================================*/
create table Users (
id int not null,
name varchar(50) null,
password varchar(50) null,
email varchar(50) null,
remarks varchar(500) null,
constraint PK_USERS primary key nonclustered (id)
)
go
SpringMVC
----------------------------------
jars of SpringMVC
com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar
com.springsource.net.sf.cglib-2.2.0.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.apache.commons.fileupload-1.2.0.jar
com.springsource.org.apache.commons.httpclient-3.1.0.jar
com.springsource.org.apache.commons.lang-2.4.0.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
com.springsource.org.apache.commons.pool-1.5.3.jar
com.springsource.org.apache.log4j-1.2.15.jar
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
com.springsource.org.codehaus.jackson.mapper-1.0.0.jar
commons-dbcp.jar
jotm.jar
org.springframework.aop-3.0.5.RELEASE.jar
org.springframework.asm-3.0.5.RELEASE.jar
org.springframework.aspects-3.0.5.RELEASE.jar
org.springframework.beans-3.0.5.RELEASE.jar
org.springframework.context-3.0.5.RELEASE.jar
org.springframework.core-3.0.5.RELEASE.jar
org.springframework.expression-3.0.5.RELEASE.jar
org.springframework.instrument-3.0.5.RELEASE.jar
org.springframework.instrument.tomcat-3.0.5.RELEASE.jar
org.springframework.jdbc-3.0.5.RELEASE.jar
org.springframework.orm-3.0.5.RELEASE.jar
org.springframework.oxm-3.0.5.RELEASE.jar
org.springframework.transaction-3.0.5.RELEASE.jar
org.springframework.web-3.0.5.RELEASE.jar
org.springframework.web.portlet-3.0.5.RELEASE.jar
org.springframework.web.servlet-3.0.5.RELEASE.jar
org.springframework.web.struts-3.0.5.RELEASE.jar
persistence.jar
xapool.jar
-----------------------------------------------
web.xml 设定applicationContext.xml,SpringMVCIbatis-servlet.xml默认位置
======================================
SpringMVCIbatis-servlet.xml
=====================================
applicationContext.xml
=====================================
HelloController.java
==========================================
WebRoot/pages/sayHello.jsp
=====================================
增加MyBatis3.0功能
jars of Project
========================================
cglib-2.2.2.jar
com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar
com.springsource.net.sf.cglib-2.2.0.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.apache.commons.fileupload-1.2.0.jar
com.springsource.org.apache.commons.httpclient-3.1.0.jar
com.springsource.org.apache.commons.lang-2.4.0.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
com.springsource.org.apache.commons.pool-1.5.3.jar
com.springsource.org.apache.log4j-1.2.15.jar
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
com.springsource.org.codehaus.jackson.mapper-1.0.0.jar
commons-dbcp.jar
commons-logging-1.1.1.jar
jotm.jar
junit-4.8.1.jar
log4j-1.2.15.jar
mybatis-3.0.4.jar
mybatis-spring-1.0.0.jar
ognl-2.6.9.jar
org.springframework.aop-3.0.5.RELEASE.jar
org.springframework.asm-3.0.5.RELEASE.jar
org.springframework.aspects-3.0.5.RELEASE.jar
org.springframework.beans-3.0.5.RELEASE.jar
org.springframework.context-3.0.5.RELEASE.jar
org.springframework.core-3.0.5.RELEASE.jar
org.springframework.expression-3.0.5.RELEASE.jar
org.springframework.instrument-3.0.5.RELEASE.jar
org.springframework.instrument.tomcat-3.0.5.RELEASE.jar
org.springframework.jdbc-3.0.5.RELEASE.jar
org.springframework.orm-3.0.5.RELEASE.jar
org.springframework.oxm-3.0.5.RELEASE.jar
org.springframework.transaction-3.0.5.RELEASE.jar
org.springframework.web-3.0.5.RELEASE.jar
org.springframework.web.portlet-3.0.5.RELEASE.jar
org.springframework.web.servlet-3.0.5.RELEASE.jar
org.springframework.web.struts-3.0.5.RELEASE.jar
persistence.jar
spring-test-3.0.5.RELEASE.jar
sqljdbc4.jar
xapool.jar
src/config/database.properties
======================================
mybatis-config.xml
========================================
applicationContext.xml
=============================
SpringMVCIbatis-servlet.xml
==============================================
log4j.properties
=================================