- Building a RESTful Web Service with Spring
- Ludovic Dewailly
- 336字
- 2021-07-09 21:44:52
Gradle
Gradle is a project automation tool that borrows a lot of concepts from Maven. It differs from Maven in using a Groovy-based declarative syntax instead of XML.
Note
Read more about Gradle at https://gradle.org. And, head over to http://www.groovy-lang.org for an introduction to Groovy.
Gradle has become a popular alternative to Maven for its flexibility and neater declarative syntax, while still offering powerful dependency management. We will take a quick look at dependency management in the next section.
Dependency management in Gradle
Gradle offers dependency resolution. It can be set up to use Maven's Central Repository. Let's consider a sample Gradle build (in a file called build.gradle
):
apply plugin: 'java' repositories { mavenCentral() }
We instructed Gradle that we want to build a Java project and that the dependencies should be fetched from Maven's Central Repository. Now, we can simply declare the dependencies we require as follows:
dependencies { runtime group: 'org.hibernate', name: 'hibernate-core', version: '4.1.9.Final' testCompile group: 'junit', name: 'junit', version: '4.+' }
The following Gradle build file declares two dependencies:
- Hibernate: This is a runtime dependency that will be used during the project compilation and will be packaged with the application
- JUnit: This dependency is added to the classpath that is used while running the tests. This type of dependency does not get included in the final application
Tip
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Maven and Gradle both offer excellent support for building our sample RESTful service, and the full build scripts can be downloaded along with all the source code of this book. Now, let's turn our attention to the structure of our property management system.
- DevOps:軟件架構師行動指南
- C++程序設計教程
- 測試驅動開發:入門、實戰與進階
- CentOS 7 Linux Server Cookbook(Second Edition)
- Architecting the Industrial Internet
- 從0到1:HTML+CSS快速上手
- Podman實戰
- C++ 從入門到項目實踐(超值版)
- 移動界面(Web/App)Photoshop UI設計十全大補
- 微服務從小白到專家:Spring Cloud和Kubernetes實戰
- 軟件供應鏈安全:源代碼缺陷實例剖析
- Python編程:從入門到實踐(第3版)
- HTML5移動Web開發
- 深入大型數據集:并行與分布化Python代碼
- Mastering XenApp?