springmvc mybatis集成配置示例

简单之美,springmvc,mybatis就是一个很好的简单集成方案,能够满足一般的项目需求。闲暇时间把项目配置文件共享出来,供大家参看:

1.首先我们来看下依赖的pom:


 
  org.springframework
  spring-core
  ${spring.version}
 

 
  org.springframework
  spring-beans
  ${spring.version}
 

 
  org.springframework
  spring-context
  ${spring.version}
 

 
  org.springframework
  spring-tx
  ${spring.version}
 

 
  org.springframework
  spring-web
  ${spring.version}
 

 
  org.springframework
  spring-webmvc
  ${spring.version}
 

 
  org.springframework
  spring-jdbc
  ${spring.version}
 

 
  org.springframework
  spring-test
  ${spring.version}
  test
 

 
 
  org.mybatis
  mybatis
  3.2.8
 

 
 
  org.mybatis
  mybatis-spring
  1.2.2
 

 
 
  mysql
  mysql-connector-java
  5.1.34
 

 
 
  com.alibaba
  druid
  1.0.12
 

 
  org.aspectj
  aspectjweaver
  1.8.4
 

 
 
  log4j
  log4j
  1.2.17
 

 
 
  javax.servlet
  servlet-api
  3.0-alpha-1
 

 
  javax.servlet
  jstl
  1.2
 

 
 
  org.codehaus.jackson
  jackson-mapper-asl
  1.9.13
 

 
  com.alibaba
  fastjson
  1.2.3
 

 
  com.fasterxml.jackson.core
  jackson-annotations
  ${jackson.version}
 

 
  com.fasterxml.jackson.core
  jackson-core
  ${jackson.version}
 

 
  com.fasterxml.jackson.core
  jackson-databind
  ${jackson.version}
 
 
 
  commons-io
  commons-io
  2.4
 

 
  commons-fileupload
  commons-fileupload
  1.2.2
 

spring 选用的是4.1.4的版本,根据系统需要我们可以选择自己适合的版本。

2.相关的配置文件:

    a)spring.xml




 
 

 
 

    b)spring-mvc.xml




 
 

 
 
 
  
  text/html;charset=UTF-8
  
 
 

 
 
 
  
  
  
  
 
 

 
 
 
 
 
 

 

  c)spring-mybatis.xml




 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 

 
 
 
 

 
 
 
 

    d)web.xml

springmvc_mybatis_demo

 
 contextConfigLocation
 classpath:spring.xml,classpath:spring-mybatis.xml
 

 
 encodingFilter
 org.springframework.web.filter.CharacterEncodingFilter
 
  encoding
  utf-8
 
 
  forceEncoding
  true
 
 
 
 encodingFilter
 /*
 

 
 org.springframework.web.context.ContextLoaderListener
 

 
 
 org.springframework.web.util.IntrospectorCleanupListener
 

 
 spring mvc servlet
 rest
 org.springframework.web.servlet.DispatcherServlet
 
  contextConfigLocation
  
  classpath:spring-mvc.xml
  
 
 1
 
 
 rest
 /
 

 
 DruidStatView
 com.alibaba.druid.support.http.StatViewServlet
 
 
 DruidStatView
 /druid/*
 

 
 
 30
 

 
 index.jsp
 

使用了druid的数据源,在web中的详细配置可以参看代码。

 以上就是对springmvc mybatis集成配置的资料整理,后续继续补充相关资料,谢谢大家对本站的支持!

你可能感兴趣的:(springmvc mybatis集成配置示例)