mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
test: 测试 Kotlin 代码生成。
This commit is contained in:
parent
9bde89f428
commit
82e189f405
@ -353,4 +353,37 @@ public class GeneratorTest {
|
||||
generator.generate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKotlinCodegen() {
|
||||
// 配置数据源
|
||||
HikariDataSource dataSource = new HikariDataSource();
|
||||
dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8");
|
||||
dataSource.setUsername("root");
|
||||
dataSource.setPassword("12345678");
|
||||
|
||||
GlobalConfig globalConfig = new GlobalConfig(GlobalConfig.FileType.KOTLIN);
|
||||
|
||||
// 设置生成文件目录和根包
|
||||
globalConfig.getPackageConfig()
|
||||
.setSourceDir(System.getProperty("user.dir") + "/src/test/java")
|
||||
.setMapperXmlPath(System.getProperty("user.dir") + "/src/test/resources/mapper")
|
||||
.setBasePackage("com.test");
|
||||
|
||||
// 设置表前缀和只生成哪些表
|
||||
globalConfig.getStrategyConfig()
|
||||
.setTablePrefix("sys_")
|
||||
.setGenerateTable("sys_user");
|
||||
|
||||
globalConfig.enableEntity();
|
||||
globalConfig.enableService();
|
||||
globalConfig.enableServiceImpl();
|
||||
globalConfig.enableMapper();
|
||||
globalConfig.enableMapperXml();
|
||||
globalConfig.enableController();
|
||||
globalConfig.enableTableDef();
|
||||
globalConfig.enablePackageInfo();
|
||||
|
||||
new Generator(dataSource, globalConfig).generate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user