1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package com.gxzc.zen
- import com.baomidou.mybatisplus.generator.AutoGenerator
- import com.baomidou.mybatisplus.generator.config.DataSourceConfig
- import com.baomidou.mybatisplus.generator.config.GlobalConfig
- import com.baomidou.mybatisplus.generator.config.StrategyConfig
- import com.baomidou.mybatisplus.generator.config.rules.DbType
- import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy
- /**
- *
- * @author NorthLan
- * @date 2018/1/24
- * @url https://noahlan.me
- */
- class Generator {
- fun main(args: Array<String>) {
- val mpg = AutoGenerator()
- // 全局配置
- val gc = GlobalConfig()
- with(gc) {
- outputDir = "D://Test"
- isFileOverride = true
- isActiveRecord = false
- isEnableCache = false
- isOpen = true
- author = "NorthLan"
- isKotlin = true
- isBaseResultMap = true
- mapperName = "%sDao"
- xmlName = "%sDao"
- serviceName = "I%sService"
- serviceImplName = "%sServiceImpl"
- }
- mpg.globalConfig = gc
- // 数据源
- val dataSource = DataSourceConfig()
- with(dataSource) {
- dbType = DbType.MYSQL
- // typeConvert
- driverName = "com.mysql.jdbc.Driver"
- username = "root"
- password = "root"
- url = "jdbc:mysql://127.0.0.1:3306/rest?characterEncoding=utf8"
- }
- mpg.dataSource = dataSource
- // 策略配置
- val strategyConfig = StrategyConfig()
- with(strategyConfig) {
- setDbColumnUnderline(true)
- // setTablePrefix()
- naming = NamingStrategy.underline_to_camel
- setInclude("user")
- setExclude("")
- setSuperEntityClass("com.gxzc.zen.persistence.ZenBaseDao")
- }
- }
- }
|