springboot之build.gradle文件详解

//构建脚本(给脚本用的脚本)
buildscript {
    //存储一个属于gradle的变量,整个工程都能用,可通过gradle.ext.springBootVersion使用
    ext {
        springBootVersion = '2.1.2.RELEASE'
    }
    /*配置仓库地址,从而找到外部依赖
    按照你在文件中(build.gradle)仓库的顺序寻找所需依赖(如jar文件),
    如果在某个仓库中找到了,那么将不再其它仓库中寻找
    */
    repositories {
        //mavenLocal()本地库,local repository(${user.home}/.m2/repository)
        mavenCentral()//maven的中央仓库
        //阿里云Maven远程仓库
        maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
    }
    /*配置springboot插件加载
    */
    dependencies {
        // classpath 声明说明了在执行其余的脚本时,ClassLoader 可以使用这些依赖项
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}
//使用以下插件
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'//jvm版本要求
// 定义仓库
repositories {
    maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
    maven{url 'https://mvnrepository.com/'}
    mavenCentral()
}
// 定义依赖:声明项目中需要哪些依赖
dependencies {
    compile  'org.springframework.boot:spring-boot-starter'
    compile('org.springframework.boot:spring-boot-starter-web')//引入web模块,springmvc
    compile  'org.springframework.boot:spring-boot-starter-test'
}
  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值