Spring Boot 项目构建 之 安装 Gradle(Chapter 4. Installing Gradle)

白话解析如下:

===========

Mac 系统下载到 Gradle 压缩包后,解压到某一目录下,然后设置环境变量,命令如下:

vi ~/.profile 

按 i 进行编辑模式,用方向键向下移动光标到末尾,并添加如下内容:

export GRADLE_HOME=/xxx/yyy/.../gradle-2.5
export PATH=$GRADLE_HOME/bin:$PATH

按 ESC 键退出编辑模式,输入 w 回车保存,再输入 q 回车退出 vi 编辑器。
接下来测试 gradle 是否可用,新开一个终端即命令行窗口,输入:

gradle -v

回车执行后,会出现如下内容,表示已成功安装可用:

------------------------------------------------------------
Gradle 2.5
------------------------------------------------------------

Build time:   2015-07-08 07:38:37 UTC
Build number: none
Revision:     093765bccd3ee722ed5310583e5ed140688a8c2b

Groovy:       2.3.10
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_40 (Oracle Corporation 25.40-b25)
OS:           Mac OS X 10.10.4 x86_64

Chapter 4. Installing Gradle

4.1. Prerequisites

Gradle requires a Java JDK or JRE to be installed, version 6 or higher (to check, use java -version). Gradle ships with its own Groovy library, therefore Groovy does not need to be installed. Any existing Groovy installation is ignored by Gradle.

Gradle uses whatever JDK it finds in your path. Alternatively, you can set the JAVA_HOME environment variable to point to the installation directory of the desired JDK.

4.2. Download

You can download one of the Gradle distributions from the Gradle web site.

4.3. Unpacking

The Gradle distribution comes packaged as a ZIP. The full distribution contains:

  • The Gradle binaries.
  • The user guide (HTML and PDF).
  • The DSL reference guide.
  • The API documentation (Javadoc and Groovydoc).
  • Extensive samples, including the examples referenced in the user guide, along with some complete and more complex builds you can use as a starting point for your own build.
  • The binary sources. This is for reference only. If you want to build Gradle you need to download the source distribution or checkout the sources from the source repository. See theGradle web site for details.

4.4. Environment variables

For running Gradle, add GRADLE_HOME/bin to your PATH environment variable. Usually, this is sufficient to run Gradle.

4.5. Running and testing your installation

You run Gradle via the gradle command. To check if Gradle is properly installed just type gradle -v. The output shows the Gradle version and also the local environment configuration (Groovy, JVM version, OS, etc.). The displayed Gradle version should match the distribution you have downloaded.

4.6. JVM options

JVM options for running Gradle can be set via environment variables. You can use either GRADLE_OPTS or JAVA_OPTS, or both. JAVA_OPTS is by convention an environment variable shared by many Java applications. A typical use case would be to set the HTTP proxy in JAVA_OPTS and the memory options in GRADLE_OPTS. Those variables can also be set at the beginning of thegradle or gradlew script.

Note that it's not currently possible to set JVM options for Gradle on the command line.

Chapter 3. Tutorials

3.1. Getting Started

The following tutorials introduce some of the basics of Gradle, to help you get started.

Chapter 4, Installing Gradle
Describes how to install Gradle.

Chapter 6, Build Script Basics
Introduces the basic build script elements: projects and tasks.

Chapter 7, Java Quickstart
Shows how to start using Gradle's build-by-convention support for Java projects.

Chapter 8, Dependency Management Basics
Shows how to start using Gradle's dependency management.

Chapter 9, Groovy Quickstart
Using Gradle's build-by-convention support for Groovy projects.

Chapter 10, Web Application Quickstart
Using Gradle's build-by-convention support for Web applications.

The latest release of Gradle is version 2.5, released on 8th July 2015.

时间: 2024-11-02 07:42:08

Spring Boot 项目构建 之 安装 Gradle(Chapter 4. Installing Gradle)的相关文章

Spring Boot 项目构建 之 使用 Gradle 构建 Java 项目(Building Java Projects with Gradle)

Table of contents What you'll build What you'll need How to complete this guide Set up the project Install Gradle Find out what Gradle can do Build Java code Declare dependencies Build your project with Gradle Wrapper Summary Tags gradle Concepts and

Spring Boot 项目构建 之 使用 Spring Boot 构建应用(Building an Application with Spring Boot)

Table of contents What you'll build What you'll need How to complete this guide Build with Gradle Build with Maven Build with Spring Tool Suite Learn what you can do with Spring Boot Create a simple web application Create an Application class Run the

使用 Spring Boot 快速构建 Spring 框架应用,PropertyPlaceholderConfigurer

Spring 框架对于很多 Java 开发人员来说都不陌生.自从 2002 年发布以来,Spring 框架已经成为企业应用开发领域非常流行的基础框架.有大量的企业应用基于 Spring 框架来开发.Spring 框架包含几十个不同的子项目,涵盖应用开发的不同方面.如此多的子项目和组件,一方面方便了开发人员的使用,另外一个方面也带来了使用方面的问题.每个子项目都有一定的学习曲线.开发人员需要了解这些子项目和组件的具体细节,才能知道如何把这些子项目整合起来形成一个完整的解决方案.在如何使用这些组件上

在Spring Boot项目中使用Spock框架

Spock框架是基于Groovy语言的测试框架,Groovy与Java具备良好的互操作性,因此可以在Spring Boot项目中使用该框架写优雅.高效以及DSL化的测试用例.Spock通过@RunWith注解与JUnit框架协同使用,另外,Spock也可以和Mockito(Spring Boot应用的测试--Mockito)协同使用. 在这个小节中我们会利用Spock.Mockito一起编写一些测试用例(包括对Controller的测试和对Repository的测试),感受下Spock的使用.

spring boot项目中处理Schedule定时任务

默认,springboot已经支持了定时任务Schedule模块,所以一般情况已经完全能够满足我们的实际需求,一般来说,没有必要在加入其他类似于:quartz 另外,在这里提一个实际项目中,关于定时任务的架构上的一些考虑: 一般来说,实际项目中,为了提高服务的响应能力,我们一般会通过负载均衡的方式,或者反向代理多个节点的方式来进行.通俗点来说,我们一般会将项目部署多实例,或者说部署多份,每个实例不同的启动端口.但是每个实例的代码其实都是一样的.如果我们将定时任务写在我们的项目中,就会面临一个麻烦

Gradle创建Spring Boot项目——1配置

第一步,创建项目并配制build.gradle文件 通过Intellij IDEA新建一个Gradle项目 在build.gradle文件中添加项目配制,执行一次Refresh all Gradle Projects buildscript { ext { springBootVersion = '1.5.4.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:

spring boot项目中使用jpa的一个未解之谜

公司最近主要的工作就是把之前的一个项目进行几乎全面的重构,之所以说几乎全面,是因为除开业务逻辑外全部换血: 框架由spring+struts2+mybatis改为spring boot+jpa 数据库由sybase+h2改为oracle+redis 子系统之间的交互由activemq改为http 代码具体实现全部重写 对一个运行了若干年的项目进行这样的大动作,路程无疑是漫长而复杂的.在进行了一系列设计文档的编写.评审.修订.再评审之后,终于可以开始码代码了. 本以为码代码终于可以松一口气,没想到

选择Spring Boot项目的内嵌容器

Spring Boot工程的默认web容器是Tomcat,但是开发人员可以根据需要修改,例如使用Jetty或者Undertow,Spring Boot提供了对应的starters. How Do 在pom文件中排除tomcat的starter <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId&g

【redis】5.spring boot项目中,直接在spring data jpa的Repository层使用redis +redis注解@Cacheable直接在Repository层使用,报错问题处理Null key returned for cache operation

spring boot整合redis:http://www.cnblogs.com/sxdcgaq8080/p/8028970.html 首先,明确一下问题的场景 之前在spring boot整合redis,关于redis的使用都是在repository层上再封装一层service层,在service层上使用的. 现在如果直接将redis的注解放在repository上使用,是个什么情况呢? 代码如下: 1.首先我有一个实体XxAdmin,主键为id 2.Xxadmin我写了一个AdminRep