gradle project mybatis-generator using automatic code generation

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/sinat_22797429/article/details/84196874

Foreword

mybatis-generator tool is used to generate the mybatis model, mapper, dao persistence code. This paper is now the mainstream build tool gradle, connect to the database automatically generate code. Although mybatis-generator does not provide gradle plug-ins, but you can use gradle call ant task, therefore, also indirectly gradle start mybatis-generator.

surroundings

  • JDK 1.8
  • IntelliJ IDEA 2017.2.2
  • Gradle 3.5.0
  • mysql

Configuration

In order shopmall-order service, for example, by arranging shopmall-order.gradle generator.xml and two files, to automatically generate the appropriate entity, mapper, xml like.

shopmall-order.gradle

description = '''shopmall-order'''

dependencies {
    compile project(":shopmall-order-api")
    compile project(':shopmall-account-api')

}

//mybatis-generator.xml 配置路径
// mac下是找不到 ./src 路径的,需要全路径,如下配置。windows则为src/main/resources/generator.xml
mybatisGenerator {
    verbose = true
    configFile = 'src/main/resources/generator.xml'
}

Guess you like

Origin blog.csdn.net/sinat_22797429/article/details/84196874