Spring Boot系列之六 以注解方式整合MyBatis
2017-04-12 17:50
961 查看
选择Mybatis的原因
本人技术历史背景原因,使用MyBatis更多.在某个阶段使用Spring-Data-JPA的过程中踩到了很多很多坑,比如说各种级联产生的json序列化问题.
本人更倾向于更自由理解起来更简单的MyBatis…(脑子不好使,没办法.)
当然Spring Boot更倾向于使用JPA.因为Spring Boot的宗旨是简单,而JPA也正好符合这一宗旨.
推荐
Java Persistence with MyBatis 3(中文版).pdf : http://download.csdn.net/detail/qq457557442/9654697
实例
pom.xmlapplication.properties
user.sql
实体映射 User
省略gettersetter方法
UserMapper
MybatisApplicationTests 测试
Mybatis中文文档
http://www.mybatis.org/mybatis-3/zh/index.html
总结
这种方式我使用的很少,没法确切的说这种做法有什么好处,什么不好. 从个人角度来看,这种做法,混淆了sql和java代码,虽然有一定的混乱,但好像更加清晰了,没有影响可读性.后文会介绍spring boot使用xml文件整合mybatis的实例,到时候大家再自己体会下吧.
代码
本文限于篇幅原因,不能展示所有的代码,如果想要完整的代码示例,请移步 https://github.com/sunshineasbefore/veryjava.spring.boot/tree/master/mybatis-annotation 支持请点赞,不喜勿喷.
每天一点点,成长多一点.
相关文章推荐
- 全注解方式整合spring+mybatis模拟springboot整合
- springboot之整合mybatis-annotation(注解方式)
- Spring boot Mybatis 整合(注解版)
- springboot使用之二:整合mybatis(xml方式)并添加PageHelper插件
- [Spring Boot实战系列] - No.3 Spring boot 整合Mybatis
- Spring+SpringMVC+mybatis+easyui整合-----注解方式的mybatis的使用
- springMVC+hibernate+jdbc+mybatis整合 支持全注解方式 支持全配置方式
- SpringBoot 快速整合Mybatis(去XML化+注解进阶)
- springboot整合mybatis使用阿里(阿里连接池)和xml方式
- 详解SpringBoot 快速整合Mybatis(去XML化+注解进阶)
- Spring-Boot整合mybatis(三)-注解的基本使用
- 5.springboot整合mybatis(注解方式)
- SpringBoot系列2—整合Mybatis-plus
- SpringMVC+MyBatis整合(注解方式)
- 2.SpringBoot系列-SpringBoot整合MyBatis
- spring mvc系列文章 - springmvc spring mybatis ibatis freemark整合开发(2.0版:基于注解)
- MyBatis学习(二):与Spring整合(非注解方式配置MyBatis)
- springboot+mybatis注解方式