• Gradle 学习笔记


    配置 Gradle 的环境变量

    export GRADLE_HOME=/opt/software/java/gradle-3.1
    export PATH=(PATH:)GRADLE_HOME/bin

    阿里巴巴的 Maven 仓库,可以设置为公共仓库,下载很快

    方法:直接在 build.gradle 的开始配置

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

    补充说明:在 Windows 操作系统上如何全局地配置共有仓库地址。

    在 init.gradle 上粘贴上面的片段即可。

    在 ext 统一声明构建的版本

    buildscript {
        ext {
            springBootVersion = '1.5.2.RELEASE'
            jacksonVersion = '2.8.5'
        }
        repositories {
            // NOTE: You should declare only repositories that you need here
            mavenLocal()
            mavenCentral()
            maven { url "http://repo.spring.io/release" }
            maven { url "http://repo.spring.io/milestone" }
            maven { url "http://repo.spring.io/snapshot" }
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        }
    }
    

    在依赖中就可以这样使用:

    dependencies {
        testCompile group: 'junit', name: 'junit', version: '4.12'
        compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: "${jacksonVersion}"
        compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${jacksonVersion}"
        compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: "${jacksonVersion}"
        compile group: 'org.hashids', name: 'hashids', version: '1.0.1'
        compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: "${springBootVersion}"
        compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: "${springBootVersion}"
        compile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: "${springBootVersion}"
        compile group: 'org.projectlombok', name: 'lombok', version: '1.16.14'
        compile group: 'commons-collections', name: 'commons-collections', version: '3.2.2'
        compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
        compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
        compile group: 'com.google.guava', name: 'guava', version: '21.0'
        compile group: 'joda-time', name: 'joda-time', version: '2.9.7'
        compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.41'
        compile group: 'com.alibaba', name: 'fastjson', version: '1.2.29'
        compile group: 'com.alibaba', name: 'druid', version: '1.0.18'
    }
    

    常用的依赖

    compile group: 'org.springframework.data', name: 'spring-data-redis', version: '1.8.1.RELEASE'
    compile group: 'redis.clients', name: 'jedis', version: '2.9.0'
    compile group: 'org.springframework.session', name: 'spring-session', version: '1.3.0.RELEASE'
    
    compile group: 'org.springframework.session', name: 'spring-session-data-redis', version: '1.3.0.RELEASE'
    compile group: 'org.springframework', name: 'spring-web', version: '4.3.7.RELEASE'
    compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.7.RELEASE'
    compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
    compile group: 'javax.servlet.jsp', name: 'javax.servlet.jsp-api', version: '2.3.2-b02'
    
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.7'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.7'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.7'
    
  • 相关阅读:
    Eclipse中项目进行发布到Tomcat中的位置
    Tomcat中server.xml文件的配置
    Tomcat的安装跟配置
    实习第二天(查看项目源代码)
    mac、windows、linux版jdk1.8下载
    idea搭建简单ssm框架的最详细教程(新)
    ssm中mapper注入失败的传奇经历
    富文本编辑器handyeditor,上传和预览图片的host地址不一样
    nginx配置ssl证书
    java中pojo对象首字母大写导致无法赋值问题
  • 原文地址:https://www.cnblogs.com/liweiwei1419/p/6766114.html
Copyright © 2020-2023  润新知