A convenient and well-designed tool for generating universal code.
+----------+ JDBC +---------------------+ TableMetadata +------------------------+
| | ------> | | ----------------> | DefinitionConverter |
| Database | | MetadataProvider | +------------------------+
| | | | |
| | | | | FileDefinition
+----------+ +---------------------+ v
+- - - - - - - - - - - - - - +
' Various of file wrappers '
' '
' +------------------------+ '
' | FileWrapper | '
' +------------------------+ '
' '
+- - - - - - - - - - - - - - +
|
|
|
+- - - - - - - - - - - - -+ |
' OUTPUT: ' |
' ' |
' XxxEntity.java ' |
' XxxMapper.xml ' |
' XxxDao.java ' |
' XxxService.java ' |
' XxxServiceImpl.java ' |
' XxxController.java ' |
' XxxVo.java ' |
' ' v
' +---------------------+ ' Parse & export +------------------------+
' | Ultimate Code Files | ' <---------------- | |
' +---------------------+ ' | FileParser |
' ' | |
+- - - - - - - - - - - - -+ +------------------------+
Step one. Configuration
-
Config datasource properties
src/main/resource/config.properties
-
Config code generation rules
Configuration configuration = new Configuration();
configuration.setTableName("t_user")
.setTablePrefix("")
.setPackageName("com.workholiday")
.setPagerPackageName("com.workholiday.base.core.page")
.setWithPager(true)
.setOutputPath("/Users/hunterzhao/tmp/output");
Step two. Generation
Launch CoffeeMaker via main
method of CoffeeMakerLauncher
.
Step three. Enjoy :D
Generate code template list:
- Entity file
- DAO file
- Mbatis mapper file
- Service file
- Service implementation file
- VO file
- Controller file
To customize code generation template by adding(editing) self-defined(existing) FileWrapper
and FileTemplate