//构建脚本(给脚本用的脚本) 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' }
springboot之build.gradle文件详解
最新推荐文章于 2024-08-07 17:36:21 发布