MAC之简单构建一个基于Gradle的SpringBoot2项目

1:首先通过 SpringBoot 官方提供的 Spring Initializr 来初始化一个Web项目。

        网址:https://start.spring.io/

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 文件。

 

5:java -jar 执行 这个jar包

6:输入http://localhost:8080 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值