You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme-en.md
+44-16Lines changed: 44 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,13 +18,22 @@ can generate whole set of MVC CRUD code for SpringBoot during compiling.
18
18
19
19
### How to customize generation templates
20
20
21
-
Just edit `xxxTemplate` value in `@MVCIntrospective`.
21
+
`@MVCIntrospective` has multiple configurable fields. Each of them has detailed description at [Javadoc](/src/main/java/firok/spring/mvci/MVCIntrospective.java).
22
22
23
-
> Resetting any of those values to `firok.spring.mvci.Constants.DISABLE` (`"##DISABLE##"`) will disable generating that code
23
+
Most of those fields are annotated with `@AvailableValues` annotation, which describes the acceptable values of the relevant fields. A field can take any custom value (usually for a template string), if `Constants.CUSTOM` is listed in a `@AvailableValues`. Or any other non-listed values would cause compile error.
24
24
25
-
> If you do not want to write a long string template for many times, you could define that value as a `public static final String` field and use it in annotation.
25
+
`PREFER_XXX` values means that those values could be overrided by upper configs. `DEFAULT` means the default value (usually a default template string) would be taken.
26
26
27
-
Default templates are stored in `firok.spring.mvci.internal.DefaultXXXTemplate`.
27
+
`@MVCIntrospective` can be annotated on `class` or `package`.
28
+
When generating for a bean class, we would search from children packages to parent packages to find any `@MVCIntrospective`. Then decide each value of fields.
29
+
30
+
> Hope you know what is `package-info.java`
31
+
32
+
### Replacing-key-value-pair for templates
33
+
34
+
You could adjust templates by editing `templateXXX` fields in `@MVCIntrospective`.
35
+
36
+
> default templates are stored in `resources` folder
28
37
29
38
When customizing templates, keys below will be replaced:
30
39
@@ -42,26 +51,45 @@ Key | Meaning | Example
42
51
`##SERVICE_IMPL_PACKAGE##` | service impl package | `firok.spring.demo.service.impl`
Most of **replacing-value** of **replacing-key** are generated from templates. However, we do not guarantee the order in which the **replacing-values** are generated.
46
55
47
-
Editing `xxxPackage` of `@MVCIntrospective` would change the package to generate; Editing `xxxName` would change the name to generate.
56
+
An extra replacement would be taken when generating `XXX_PACKAGE##`, which would replace the `\.entity|bean\.` to `.mapper.`, `.service.`, `.service_impl.` or `.controller.`.
57
+
58
+
> For a bean class `a.b.c.entity.d.e.TestEntity`,
59
+
> package for controller should be `a.b.c.controller.d.e`
60
+
61
+
Except default replacing-key-value-pairs, you could create custom ones by editing `extraParams` of `@MVCIntrospective`. If multiple configs contain the same **replacing-key**, the **replacing-value** closer to bean class definition would be adopted.
62
+
63
+
> `a.b` → `##TEST## = "test"`
64
+
> `a.b.c` → `##TEST## = "test2"`,
65
+
> `a.b.c.TestBean` → `##TEST## = "test3"`,
66
+
> `a.b.c.TestBean` ← `##TEST## = "test3"`,
67
+
> `a.b.c.Test2Bean` ← `##TEST## = "test2"`,
68
+
> `a.b.DemoBean` ← `##TEST## = "test"`
48
69
49
70
## Something else
50
71
51
72
**MVCI itself** is not based on SpringBoot and MybatisPlus. But **the default templates used by MVCI** is based on SpringBoot and MybatisPlus.
52
73
By default, you should import them as dependencies, or the project will not pass the compilation.
53
74
54
-
A usable maven dependency is:
75
+
In addition, you need to properly import dependencies such as database drivers, or your project may not work properly.
MVCI has only passed testing under **Java17**. It may work in lower version of Java. But you may need to edit the `@SupportedSourceVersion` value of `firok.spring.mvci.MVCIntrospectProcessor` and some code of MVCI.
63
78
64
-
In addition, you need to properly import dependencies such as database drivers, or your project may not work properly.
79
+
## Changelog
80
+
81
+
### 17.1.1
82
+
83
+
* minor code improvements
84
+
85
+
### 17.1.0
86
+
87
+
* now we could adjust generation on package level
88
+
89
+
### 17.0.0
90
+
91
+
* increased supported JDK version to 17
65
92
66
-
MVCI has only passed testing under **Java16**. It may work in lower version of Java. But you may need to edit the `@SupportedSourceVersion` value of `firok.spring.mvci.MVCIntrospectProcessor` and some code of MVCI.
0 commit comments