1.导包
Mybatis的jar包
asm-4.2.jar
cglib-3.1.jar
commons-logging-1.2.jar
log4j-1.2.17.jar
log4j-api-2.2.jar
log4j-core-2.2.jar
mybatis-3.3.0.jar
mysql-connector-java.jar
slf4j-api-1.7.12.jar
slf4j-log4j12-1.7.12.jar
Spring+SpringMVC+ORM
spring-beans-3.2.0.RELEASE.jar
spring-context-3.2.0.RELEASE.jar
spring-core-3.2.0.RELEASE.jar
spring-expression-3.2.0.RELEASE.jar
spring-jdbc-3.2.0.RELEASE.jar
spring-orm-3.2.0.RELEASE.jar
spring-test-3.2.0.RELEASE.jar
spring-web-3.2.0.RELEASE.jar
spring-webmvc-3.2.0.RELEASE.jar
aop+tx
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.aspectj.tools-1.6.6.RELEASE.jar
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
spring-aop-3.2.0.RELEASE.jar
spring-aspects-3.2.0.RELEASE.jar
spring-tx-3.2.0.RELEASE.jar
jackson
jackson-annotations-2.5.4.jar
jackson-core-2.5.4.jar
jackson-databind-2.5.4.jar
spring和mybatis整合需要的jar包
mybatis-spring-1.2.0.jar
c3p0连接池
com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar
文件上传
com.springsource.org.apache.commons.fileupload-1.2.0.jar
com.springsource.org.apache.commons.io-1.4.0.jar
2.配置文件
2.1 web.xml
1.启动Spring容器
2.配置SpringMVC核心控制器
3.配置Spring编码过滤器
2.2 applicationContext.xml
(用注释的方式写)
1.扫描service和dao下的注释
2.配置数据源,用c3p0(注意用户名用“user”,不用的话会访问不了数据库)
3.整合Mybatis
①将数据源配入
②注入配置文件mybatis-config.xml
③扫描mapper包下的xml
4.配置事务
2.3 mybatis-config.xml
配置别名(其他的都在applicationContext.xml配完了)
2.4 springmvc-servlet.xml
1.配置视图解析器
2.配置文件上传解析器
3.配置json解析器
2.5 DaoImpl.java
继承SqlSessionDaoSupport,并重写setSqlSessionFactory方法
在方法上面还要加上注释 @Autowired