Spring Boot & Mybatis

2018-08-05  本文已影响38人  大批

Mybatis简介

项目依赖(仅仅是java项目)

        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.38</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.12</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.12</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

Mybatis的mapper,xml 和 接口

    <mappers>
        <mapper resource="mapper\CountryMapper.xml"/>
    </mappers>
    <mappers>
        <package name="com.suse.yudapi.mapper"/>
    </mappers>

枚举处理

    <typeHandlers>
        <typeHandler handler="org.apache.ibatis.type.EnumOrdinalTypeHandler"
                     javaType="com.suse.yudapi.model.CountryType"/>
    </typeHandlers>

Spring Boot Mybatis

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.2</version>
        </dependency>
mybatis.mapperLocations="classpath:mapper/*.xml"
mybatis.typeAliasesPackage="com.suse.model"
mybatis.typeHandlersPackage=""
mybatis.configuration.mapUnderscoreToCamelCase=""

 
End

[3]  spring boot JPA
[2]  ...

上一篇下一篇

猜你喜欢

热点阅读