输入网址:https://start.spring.io 构建springboot项目
1.下载gradle
地址:http://services.gradle.org/distributions/
注意:gradle尽量使用高版本,我使用3.5.1时就遇到了插件和gradle不兼容导致构建失败的问题。
2.配置环境变量
3.构建项目并启动
//构建项目 gradle build //启动项目 java -jar 项目名称
build.gradle文件为gradle的构建脚本
buildscript { ext {//动态属性 可使用${} 使用 springBootVersion = '2.0.3.RELEASE' } repositories { //仓库 mavenCentral() //默认的中央仓库,在国外,速度慢 } dependencies {//依赖 classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' group = 'com.example' version = '0.0.1-SNAPSHOT' //项目版本 sourceCompatibility = 1.8 //jdk版本 repositories { //仓库 mavenCentral() } dependencies {//依赖 compile('org.springframework.boot:spring-boot-starter-web') testCompile('org.springframework.boot:spring-boot-starter-test') }
gradle文件夹的warpper可以统一项目的版本,并且如果本机为装有gradle时可使用此文件进行项目构建
可以在gradle-wapper.properties中修改版本