File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
src/main/resources/META-INF Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 26
26
<version >1.1.0</version >
27
27
</dependency >
28
28
```
29
+ ## Spring DevTools 配置
30
+ 感谢[ emf1002] ( https://github.com/emf1002 ) 提供的解决方案。
31
+
32
+ 在使用 DevTools 时,通用Mapper经常会出现 class x.x.A cannot be cast to x.x.A。
33
+
34
+ 同一个类如果使用了不同的类加载器,就会产生这样的错误,所以解决方案就是让通用Mapper和实体类使用相同的类加载器即可。
35
+
36
+ DevTools 默认会对 IDE 中引入的所有项目使用 restart 类加载器,对于引入的 jar 包使用 base 类加载器,因此只要保证通用Mapper的jar包使用 restart
37
+ 类加载器即可。
38
+
39
+ 在 ` src/main/resources ` 中创建 META-INF 目录,在此目录下添加 spring-devtools.properties 配置,内容如下:
40
+ ``` properties
41
+ restart.include.mapper =/mapper-[\\w-\\.]+jar
42
+ restart.include.pagehelper =/pagehelper-[\\w-\\.]+jar
43
+ ```
44
+ 使用这个配置后,就会使用 restart 类加载加载 include 进去的 jar 包。
29
45
30
46
## 集成 MyBatis Generator
31
47
通过 Maven 插件集成的,所以运行插件使用下面的命令:
@@ -75,7 +91,6 @@ pagehelper:
75
91
params : count=countSql
76
92
` ` `
77
93
78
-
79
94
注意 mapper 配置,因为参数名固定,所以接收参数使用的对象,按照 Spring Boot 配置规则,大写字母都变了带横线的小写字母。针对如 IDENTITY(对应i-d-e-n-t-i-t-y)提供了全小写的 identity 配置,如果 IDE 能自动提示,看自动提示即可。
80
95
81
96
## SSM集成的基础项目
Original file line number Diff line number Diff line change 40
40
<groupId >org.springframework.boot</groupId >
41
41
<artifactId >spring-boot-starter-test</artifactId >
42
42
</dependency >
43
+ <dependency >
44
+ <groupId >org.springframework.boot</groupId >
45
+ <artifactId >spring-boot-devtools</artifactId >
46
+ <optional >true</optional >
47
+ </dependency >
43
48
44
49
<dependency >
45
50
<groupId >mysql</groupId >
Original file line number Diff line number Diff line change
1
+ restart.include.mapper =/mapper-[\\w-\\.]+jar
2
+ restart.include.pagehelper =/pagehelper-[\\w-\\.]+jar
You can’t perform that action at this time.
0 commit comments