mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
doc: update docs
This commit is contained in:
parent
1ea36328ff
commit
0d4e00ec9d
@ -30,7 +30,7 @@ export default defineConfig({
|
||||
{text: '帮助文档', link: '/zh/intro/what-is-mybatisflex'},
|
||||
{text: '🆘 常见问题', link: '/zh/faq'},
|
||||
{text: '周边 / 视频教程', link: '/zh/awesome-things'},
|
||||
{text: '代码生成器', link: '/zh/others/codegen.md'},
|
||||
{text: '🍷代码生成器', link: '/zh/others/codegen.md'},
|
||||
{text: '更新日志', link: '/zh/changes'},
|
||||
{text: 'JavaDoc', link: 'https://apidoc.gitee.com/mybatis-flex/mybatis-flex/'},
|
||||
|
||||
|
||||
@ -204,10 +204,13 @@ spring:
|
||||
|
||||
## 代码生成器获取不到注释
|
||||
|
||||
如果是 MySQL 数据库的话,可能是因为数据库版本太低,解决办法:MySQL 5.* 需要在 jdbcUrl 设置参数 `useInformationSchema=true` 才能获取到注释。
|
||||
如果是 MySQL 数据库的话,可能是因为数据库版本太低,解决办法:在 jdbcUrl 设置参数 `useInformationSchema=true` 才能获取到注释。
|
||||
|
||||
例如:`jdbc:mysql://127.0.0.1:3306/mybatis-flex?characterEncoding=UTF-8&useInformationSchema=true`
|
||||
|
||||
|
||||
如果是 Oracle, 则需要添加参数 `remarksReporting=true` ,例如:`jdbc:oracle:thin:@localhost:1521:orcl?remarksReporting=true`
|
||||
|
||||
## 与 Nacos 集成时出错,无法正常启动 MyBatis-Flex
|
||||
|
||||
一般情况下,是因为缺少 Nacos 的相关 Maven,注意添加如下的 Nacos 依赖:
|
||||
@ -229,7 +232,7 @@ FlexConfiguration configuration = new FlexConfiguration();
|
||||
MybatisFlexBootstrap.getInstance().setConfiguration(configuration);
|
||||
```
|
||||
|
||||
2、在使用 Spring-Boot 的场景下:
|
||||
2、在使用 SpringBoot 的场景下:
|
||||
|
||||
```java
|
||||
@Configuration
|
||||
@ -243,7 +246,7 @@ public class MyConfigurationCustomizer implements ConfigurationCustomizer {
|
||||
}
|
||||
```
|
||||
|
||||
3、只使用 Spring(不使用 Spring-Boot ) 的场景:
|
||||
3、只使用 Spring(不使用 SpringBoot ) 的场景:
|
||||
|
||||
```java
|
||||
@Bean
|
||||
|
||||
@ -1,12 +1,17 @@
|
||||
# MyBatis-Flex 代码生成器
|
||||
|
||||
在 mybatis-flex 的模块 `mybatis-flex-codegen` 中,提供了可以通过数据库表,生成 Entity 类和 Mapper 类的功能。当我们把数据库表设计完成
|
||||
后可以使用其快速生成 Entity、 Mapper、 Service、 Controller 等产物。 除此之外,我们还可以通过扩展生成更多种类的物料。
|
||||
## 简介
|
||||
|
||||
在使用前先添加 `mybatis-flex-codegen` 的 Maven 依赖:
|
||||
在 mybatis-flex 中,有了一个名称为 `mybatis-flex-codegen` 的模块,提供了可以通过数据库表,生成代码的功能。当我们把数据库表设计完成后,
|
||||
就可以使用其快速生成 Entity、 Mapper、 Service、 Controller 等产物。
|
||||
|
||||
除此之外,我们还可以通过扩展生成更多的产物,文档参考 [#添加其他产物的生成](#添加其他产物的生成)。
|
||||
|
||||
## 快速开始
|
||||
|
||||
在使用之前,我们需要先添加 `mybatis-flex-codegen` 的 Maven 依赖:
|
||||
|
||||
```xml
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-codegen</artifactId>
|
||||
@ -122,7 +127,7 @@ public class Codegen {
|
||||
|
||||
关闭 APT 的 Mapper 类文件生成,请参考:[APT 设置章节](../others/apt.md)
|
||||
|
||||
## 使用介绍
|
||||
## 功能介绍
|
||||
|
||||
在 Mybatis-Flex 的代码生成器中,支持如下 8 种类型的的产物生成:
|
||||
|
||||
@ -135,6 +140,8 @@ public class Codegen {
|
||||
- MapperXml 文件
|
||||
- package-info.java 文件
|
||||
|
||||
> 除此之外,我们可以添加扩展生成更多类型的产物,文档参考 [#添加其他产物的生成](#添加其他产物的生成)。
|
||||
|
||||
启用或关闭某种类型产物的生成,代码如下:
|
||||
|
||||
```java
|
||||
@ -155,7 +162,7 @@ globalConfig.enableEntity()
|
||||
|
||||
## 全局配置 `GlobalConfig`
|
||||
|
||||
> 可以像先前一样直接使用 `setXxx()` 进行配置,也可以使用 `getXxxConfig().setXxx()` 进行分类配置。
|
||||
### 详细配置
|
||||
|
||||
| 获取配置 | 描述 |
|
||||
|------------------------|------------------|
|
||||
@ -233,7 +240,7 @@ globalConfig.getJavadocConfig()
|
||||
|
||||
```java
|
||||
globalConfig.getPackageConfig()
|
||||
.setSourceDir("D://files/java")
|
||||
.setSourceDir("D:\\files\\java")
|
||||
.setBasePackage("com.your.domain");
|
||||
```
|
||||
|
||||
@ -277,7 +284,7 @@ globalConfig.getStrategyConfig()
|
||||
```java
|
||||
globalConfig.getTemplateConfig()
|
||||
.setTemplate(new FreeMarkerTemplate())
|
||||
.setEntity("D:\your-template-file\my-entity.tpl");
|
||||
.setEntity("D:\\your-template-file\\my-entity.tpl");
|
||||
```
|
||||
|
||||
## Entity 生成配置 `EntityConfig`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user