MyBatis SpringMVC整合实现步骤详解

网友投稿 274 2022-11-25


MyBatis SpringMVC整合实现步骤详解

1、添加spring相关jar包

2、配置ehcache jar包。

3、添加ehcache mybatis 适配器jar包(在mybatis官网)

4、添加spring mybatis 适配器jar包(在mybatis)官网

5、pom.xml

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.ntjr.mybatisSpring

mybatisSpring

0.0.1-SNAPSHOT

war

3.4.2

5.1.38

4.3.7.RELEASE

org.mybatis

mybatis

${mybatis_version}

mysql

mysql-connector-java

${mysql_connector_version}

log4j

log4j

1.2.16

org.springframework

spring-webmvc

${org.springframework}

org.springframework

spring-tx

${org.springframework}

org.springframework

spring-jdbc

${org.springframework}

org.springframework

spring-orm

${org.springframework}

org.aopalliance

com.springsource.org.aopalliance

1.0.0

net.sourceforge.cglib

com.springsource.net.sf.cglib

2.2.0

org.aspectj

com.springsource.org.aspectj.weaver

1.6.10.RELEASE

com.mchange

c3p0

0.9.5.2

org.mybatis.caches

mybatis-ehcache

1.1.0

org.mybatis

mybatis-spring

1.3.1

commons-logging

commons-logging

1.2

TCTpSH

org.apache.taglibs

taglibs-standard-impl

1.2.5

org.apache.taglibs

taglibs-standard-spec

1.2.5

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.ntjr.mybatisSpring

mybatisSpring

0.0.1-SNAPSHOT

war

3.4.2

5.1.38

4.3.7.RELEASE

org.mybatis

mybatis

${mybatis_version}

mysql

mysql-connector-java

${mysql_connector_version}

log4j

log4j

1.2.16

org.springframework

spring-webmvc

${org.springframework}

org.springframework

spring-tx

${org.springframework}

org.springframework

spring-jdbc

${org.springframework}

org.springframework

spring-orm

${org.springframework}

org.aopalliance

com.springsource.org.aopalliance

1.0.0

net.sourceforge.cglib

com.springsource.net.sf.cglib

2.2.0

org.aspectj

com.springsource.org.aspectj.weaver

1.6.10.RELEASE

com.mchange

c3p0

0.9.5.2

org.mybatis.caches

mybatis-ehcache

1.1.0

org.mybatis

mybatis-spring

1.3.1

commons-logging

commons-logging

1.2

TCTpSH

org.apache.taglibs

taglibs-standard-impl

1.2.5

org.apache.taglibs

taglibs-standard-spec

1.2.5

6、applicationContext.xml

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"

xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd

http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd

http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-4.0.xsd

http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.0.xsd">

expression="org.springframework.stereotype.Controller" />

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"

xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd

http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd

http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-4.0.xsd

http://springframework.org/schema/context http://springframework.org/schema/context/spring-context-4.0.xsd">

expression="org.springframework.stereotype.Controller" />

expression="org.springframework.stereotype.Controller" />

7、mybatis-config.xml

PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

注意:此处mybatis配置文件中没有配置数据源,数据源由spring负责。

此外还需要ehcache.xml配置文件,Mapper.xml文件。

注意:此处mybatis配置文件中没有配置数据源,数据源由spring负责。

此外还需要ehcache.xml配置文件,Mapper.xml文件。


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:基于SpringBoot核心原理(自动配置、事件驱动、Condition)
下一篇:Spring Web零xml配置原理以及父子容器关系详解
相关文章

 发表评论

暂时没有评论,来抢沙发吧~