-
Notifications
You must be signed in to change notification settings - Fork 15
MybatisR2dbcGenerator
GangCheng edited this page Jan 22, 2024
·
2 revisions
- The
mybatis-r2dbc-generator
is aimed to generate classes used bymybatis-dynamic-sql
, and make it compatible withmybatis-r2dbc
. - Generator usage:
- import dependencies
<dependencies>
<dependency>
<groupId>org.mybatis.dynamic-sql</groupId>
<artifactId>mybatis-dynamic-sql</artifactId>
<version>${spedific-version}</version>
</dependency>
<!-- test scope -->
<!-- JDBC database driver for generator -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pro.chenggang</groupId>
<artifactId>mybatis-r2dbc-generator</artifactId>
<version>${compatible-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
- Copy
mybatis-generator.yml
to yoursrc/java/test/resources
directory. - Modify target database settings in
mybatis-generator.yml
, more detail please see themybatis-generator.yml
's comment inline. - Customize the generator runtime settings in test source root
// generate through test method @Test public void generateWithYamlWithJunitTestMethod() { MybatisDynamicCodeGenerator.withYamlConfiguration() .customConfigure() // When using test method to run generator execution, the base package location would automatically determined by current test class .applyGenerateBasePackageFromClass(MyBatisGeneratorAction.class) .configureGeneratedJavaTypeModifier(TestJavaTypeModifier.class) .toGenerator() .generate(); }
/** * generate through main method * * @param args args */ public static void main(String[] args) { String codeAbsoluteLocation = new File("").getAbsolutePath() + "/mybatis-r2dbc-generator"; MybatisDynamicCodeGenerator.withYamlConfiguration() .customConfigure() // When using main method to run generator execution, the base package location should be configured manually .configureGenerateBasePackage(codeAbsoluteLocation, "pro.chenggang.project.reactive.mybatis.support.generator") .configureGeneratedJavaTypeModifier(TestJavaTypeModifier.class) .toGenerator() .generate(); }
- Demo Generator Test
- Associated Concept
- Basic Operation Instruction
- Integration with Spring Framework