Board logo

标题: Spring Boot 与 Kotlin 整合MyBatis(1) [打印本页]

作者: look_w    时间: 2019-3-4 20:53     标题: Spring Boot 与 Kotlin 整合MyBatis(1)

创建项目,在build.gradle文件中引入依赖

    compile "org.mybatis.spring.boot:mybatis-spring-boot-startermybatis_version"
    compile "mysql:mysql-connector-javamysql_version"

完整的build.gradle文件

    group 'name.quanke.kotlin'
    version '1.0-SNAPSHOT'
     
    buildscript {
        ext.kotlin_version = '1.2.10'
        ext.spring_boot_version = '1.5.4.RELEASE'
        ext.springfox_swagger2_version = '2.7.0'
        ext.mysql_version = '5.1.21'
        ext.mybatis_version = '1.1.1'
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-pluginkotlin_version"
            classpath("org.springframework.boot:spring-boot-gradle-pluginspring_boot_version")
     
    //        Kotlin整合SpringBoot的默认无参构造函数,默认把所有的类设置open类插件
            classpath("org.jetbrains.kotlin:kotlin-noargkotlin_version")
            classpath("org.jetbrains.kotlin:kotlin-allopenkotlin_version")
        }
    }
     
    apply plugin: 'kotlin'
    apply plugin: "kotlin-spring" // See https://kotlinlang.org/docs/refe ... ing-compiler-plugin
    apply plugin: 'org.springframework.boot'
    apply plugin: "kotlin-jpa"  //https://stackoverflow.com/questions/32038177/kotlin-with-jpa-default-constructor-hell
    jar {
        baseName = 'chapter11-6-5-service'
        version = '0.1.0'
    }
    repositories {
        mavenCentral()
    }
     
     
    dependencies {
        compile "org.jetbrains.kotlin:kotlin-stdlib-jre8kotlin_version"
        compile("org.jetbrains.kotlin:kotlin-reflect{kotlin_version}")
     
     
        compile "org.mybatis.spring.boot:mybatis-spring-boot-startermybatis_version"
     
        compile "mysql:mysql-connector-javamysql_version"
     
        testCompile "org.springframework.boot:spring-boot-starter-test:$spring_boot_version"
        testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
     
    }
     
    compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
    compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0