springboot + Gradle 的build.gradle 配置

  • 搞了将近几天,才把 maven 仓库,以及log4J配好,之前总是报证书,还有栈溢出的错误,下面是我踩坑之后可以使用的 build.gradle 配置
  • 我看网上说 implementation 这个引包比较好
  • 我这个只搞了 2.1.4.RELEASE 可以使用,其他的还没试过
buildscript {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google'}
        maven { url 'https://maven.aliyun.com/repository/jcenter'}
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public'}
    }
}

plugins {
    id 'org.springframework.boot' version '2.1.4.RELEASE'
    id 'java'
}

apply plugin: 'io.spring.dependency-management'

configurations {
    providedRuntime
    // remove default logger 排除默认的 logger
    compile.exclude module: 'spring-boot-starter-logging'
}

dependencies {

    //中间件连接Spring Boot和MyBatis
    implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.1'
    //测试
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    //web
    implementation 'org.springframework.boot:spring-boot-starter-web'

    //引入依赖的jar包 以及 自己的自定义配置的jar包
    implementation 'org.springframework.boot:spring-boot-starter'
    //添加log4j2依赖
    implementation 'org.springframework.boot:spring-boot-starter-log4j2'
    //加上这个才能辨认到log4j2.yml文件
    implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'

    //lombok(自动生成 getter / setter 的构造方法)
    compileOnly 'org.projectlombok:lombok:1.18.4'
    //pageHelper 插件
    implementation 'com.github.pagehelper:pagehelper-spring-boot-starter:1.2.5'

    //SqlServer 数据库连接
    implementation 'com.microsoft:sqljdbc4:3.0'
    //MySql 数据库连接
    implementation 'mysql:mysql-connector-java'
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google'}
        maven { url 'https://maven.aliyun.com/repository/jcenter'}
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public'}
    }
}

你可能感兴趣的:(Gradle)