Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Spring Boot集成MyBatis的基础项目

NotificationsYou must be signed in to change notification settings

coder-java-caicai/MyBatis-Spring-Boot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#Spring Boot集成MyBatis的基础项目

#MyBatis3.3.0

#Spring Boot 1.3.0.RELEASE

项目使用Spring Boot 1.3.0.RELEASE + Mybatis3.3.0

项目集成了Mybatis分页插件和通用Mapper插件

项目使用的mysql数据库,根据需要可以切换为其他数据库

##重要提示

本项目一开始对@AutoConfigureAfter 的用法有问题,详细内容请看:

Spring Boot - 配置排序依赖技巧

本项目已经按照上文的技巧对包和用法做了修改,基本上可以保证 100% 没错。

##说明

虽然MyBatis官方提供了mybatis-spring-boot-starter,但是该配置的可以控制的地方太少,因此短时间不会直接使用该starter

在集成MyBatis配置MapperScannerConfigurer需要特别注意,将该类单独放在一个配置文件中,例如本项目中的MyBatisMapperScannerConfig类:

@Configuration//注意,由于MapperScannerConfigurer执行的比较早,所以必须有下面的注解//MyBatisConfig.class是一个包含了SqlSessionFactory配置的类@AutoConfigureAfter(MyBatisConfig.class)publicclassMyBatisMapperScannerConfig {@BeanpublicMapperScannerConfigurermapperScannerConfigurer() {MapperScannerConfigurermapperScannerConfigurer =newMapperScannerConfigurer();mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");mapperScannerConfigurer.setBasePackage("tk.mybatis.springboot.mapper");Propertiesproperties =newProperties();properties.setProperty("mappers","tk.mybatis.springboot.util.MyMapper");properties.setProperty("notEmpty","false");properties.setProperty("IDENTITY","MYSQL");//这里使用的通用Mapper的MapperScannerConfigurer,所有有下面这个方法mapperScannerConfigurer.setProperties(properties);returnmapperScannerConfigurer;    }}

##SSM集成的基础项目

###https://github.com/abel533/Mybatis-Spring

##MyBatis工具

###http://www.mybatis.tk

##推荐使用Mybatis通用Mapper3

###https://github.com/abel533/Mapper

##推荐使用Mybatis分页插件PageHelper

###https://github.com/pagehelper/Mybatis-PageHelper

##作者信息

About

Spring Boot集成MyBatis的基础项目

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java81.7%
  • FreeMarker14.6%
  • CSS3.7%

[8]ページ先頭

©2009-2025 Movatter.jp