1:首先通过 SpringBoot 官方提供的 Spring Initializr 来初始化一个Web项目。
2:通过步骤一下载到本地
解压后目录(注意我的项目名为book)
3: 这一步可选,build.gradle 文件中的maven仓库地址改为 阿里云 的地址
(编译时下载依赖的速度会快点)
buildscript {
ext {
springBootVersion = '2.1.0.RELEASE'
}
repositories {
// mavenCentral()
// 将 build.gradle 文件中的maven仓库地址改为 阿里云 的地址
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}
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.yu'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
// mavenCentral()
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
4:通过命令行编译项目
在项目根目录使用gradle build
编译完成会在项目目录中生成一个 build目录,在目录下的 libs下有个可执行的 jar 文件。