2
2
3
3
- [ Spring Boot 1.5.1.RELEASE] ( https://github.com/spring-projects/spring-boot )
4
4
- [ mybatis-spring-boot-starter 1.1.1] ( https://github.com/mybatis/spring-boot-starter )
5
- - [ mapper-spring-boot-starter 1.0 .0] ( https://github.com/abel533/mapper-boot-starter )
5
+ - [ mapper-spring-boot-starter 1.1 .0] ( https://github.com/abel533/mapper-boot-starter )
6
6
- [ pagehelper-spring-boot-starter 1.1.0] ( https://github.com/pagehelper/pagehelper-spring-boot )
7
7
8
8
## 项目依赖
17
17
<dependency >
18
18
<groupId >tk.mybatis</groupId >
19
19
<artifactId >mapper-spring-boot-starter</artifactId >
20
- <version >1.0 .0</version >
20
+ <version >1.1 .0</version >
21
21
</dependency >
22
22
<!-- pagehelper-->
23
23
<dependency >
27
27
</dependency >
28
28
```
29
29
30
+ ## 集成 MyBatis Generator
31
+ 通过 Maven 插件集成的,所以运行插件使用下面的命令:
32
+ > mvn mybatis-generator: generate
33
+
34
+ Mybatis Geneator 详解:
35
+ > http://blog.csdn.net/isea533/article/details/42102297
36
+
37
+ ## application.properties 配置
38
+ ``` properties
39
+ # mybatis
40
+ mybatis.type-aliases-package =tk.mybatis.springboot.model
41
+ mybatis.mapper-locations =classpath:mapper/*.xml
42
+
43
+ # mapper
44
+ # mappers 多个接口时逗号隔开
45
+ mapper.mappers =tk.mybatis.springboot.util.MyMapper
46
+ mapper.not-empty =false
47
+ mapper.identity =MYSQL
48
+
49
+ # pagehelper
50
+ pagehelper.helperDialect =mysql
51
+ pagehelper.reasonable =true
52
+ pagehelper.supportMethodsArguments =true
53
+ pagehelper.params =count =countSql
54
+ ```
55
+
30
56
## application.yml 配置
31
57
32
- 完整配置可以参考 [ src/main/resources/application.yml] ( https://github.com/abel533/MyBatis-Spring-Boot/blob/master/src/main/resources/application.yml ) ,和 MyBatis 相关的部分配置如下:
58
+ 完整配置可以参考 [ src/main/resources/application-old .yml] ( https://github.com/abel533/MyBatis-Spring-Boot/blob/master/src/main/resources/application-old .yml ) ,和 MyBatis 相关的部分配置如下:
33
59
34
60
``` yaml
35
61
mybatis :
@@ -49,25 +75,6 @@ pagehelper:
49
75
params : count=countSql
50
76
` ` `
51
77
52
- ## application.properties 配置
53
- 因为使用这种方式的人多,为了避免部分人看不懂上面的配置方式,这里提供 properties 方式的配置
54
- ` ` ` properties
55
- # mybatis
56
- mybatis.type-aliases-package=tk.mybatis.springboot.model
57
- mybatis.mapper-locations=classpath:mapper/*.xml
58
-
59
- # mapper
60
- # mappers 多个接口时逗号隔开
61
- mapper.mappers=tk.mybatis.springboot.util.MyMapper
62
- mapper.not-empty=false
63
- mapper.identity=MYSQL
64
-
65
- # pagehelper
66
- pagehelper.helperDialect=mysql
67
- pagehelper.reasonable=true
68
- pagehelper.supportMethodsArguments=true
69
- pagehelper.params=count=countSql
70
- ```
71
78
72
79
注意 mapper 配置,因为参数名固定,所以接收参数使用的对象,按照 Spring Boot 配置规则,大写字母都变了带横线的小写字母。针对如 IDENTITY(对应i-d-e-n-t-i-t-y)提供了全小写的 identity 配置,如果 IDE 能自动提示,看自动提示即可。
73
80
0 commit comments