MyBatis-generator+SpringBoot+Gradle配置

Gradle配置

直接从现在的项目修改贴下来的,里面有不少的非必须项…

可以看看上面的参考里的文章。

buildscript {
   ext {
      springBootVersion = '2.0.0.RELEASE'
   }
   repositories {
      mavenCentral()
      //添加maven仓库 mybatis-generetor
      maven {
         url "https://plugins.gradle.org/m2/"
      }
   }
   dependencies {
      classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")

      // mybatis-generator 插件路径mybatis-generetor
      classpath "gradle.plugin.com.arenagod.gradle:mybatis-generator-plugin:1.4"
   }
}
//配置从阿里云源下载依赖
allprojects {
   repositories {
      maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
      maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
   }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
//引入 mybatis-generator 插件mybatis-generetor
apply plugin: "com.arenagod.gradle.MybatisGenerator"

group = 'com.swpu'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
   mavenCentral()
}

configurations {
   //这里需要使用 MyBatis Generator,MySQL 驱动,以及 MyBatis Mapper.
   //由于代码生成单独运行即可,不需要参与到整个项目的编译,因此在 build.gradle 中添加配置:
   mybatisGenerator
}

dependencies {
   compile('org.springframework.boot:spring-boot-starter-web')

   // mybatis
   compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1')

   // https://mvnrepository.com/artifact/mysql/mysql-connector-java
   compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.45'

   // https://mvnrepository.com/artifact/com.alibaba/fastjson
   compile group: 'com.alibaba', name: 'fastjson', version: '1.2.47'

   //mybatis-geerator
   // https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core
   compile group: 'org.mybatis.generator', name: 'mybatis-generator-core', version: '1.3.6'

}

// mybatis-generator.xml 配置路径
mybatisGenerator {
   verbose = true
   configFile = 'src/main/resources/mybatis/generator.xml'
}

配置

在项目配置文件中配置基本信息

我用的 yml 配置

spring:
  datasource:
    url: jdbc:mysql://118.126.xxx.xxx:3306/test?serverTimezone=UTC
    username: xxxx
    password: xxxxx
    driver-class-name: com.mysql.jdbc.Driver
mybatis:
  #实体类所做包
  type-aliases-package: learning.model2
  #mapper.xml所在位置
  mapper-locations: classpath:mappers/*.xml

设置生成代码的配置文件

在 generatorConfig.xml 中配置数据库表信息




    

        
        

        
        
            
        

        
        
        

        
        
        
            
            
            
            
        

        
        
        
            
            
        

        
        
        
            
            
        

        
        

        
        

 

你可能感兴趣的:(springboot,逆向工程)