Gradle Creating a Spring-boot Project

Source: Internet
Author: User

Just came to the new company, familiar with the company's Project building framework, learned a new project management tools: Gradle, from the Internet, is said to be more flexible than Maven, so they learned a little. Write it down and use it again later. Gradle installation will not say, Take a grab on the net. Directly say create Spring-boot process.

1. First of all, initialize the Gradle project

Gradle Init

After initialization, the standard Gralde directory is generated under the project.

. ├──build.gradle├──gradle│└──wrapper│     ├──gradle-wrapper.jar│     └──gradle-WRAPPER.P Roperties├──gradlew├──gradlew.bat└──settings.gradle

Here we mainly edit the "build.gradle" file

2. Edit Build.gradle

1 Buildscript {2     //here the main add spring-boot of the plug -in warehouse3 Repositories {4Maven {URL "https://repo.spring.io/libs-release"}5 mavenlocal ()6 mavencentral ()7     }8 Dependencies {9Classpath ("Org.springframework.boot:spring-boot-gradle-plugin:1.2.3.release")Ten     } One } A  - //using plugins -Apply plugin: ' java ' theApply plugin: ' Eclipse ' -Apply plugin: ' Idea ' -Apply plugin: ' Spring-boot ' -  + //packaged as a jar package - Jar { +BaseName = "Spring_boot_test" AVersion = ' 0.1 ' at } -  - //Add Warehouse - Repositories { - mavenlocal () - mavencentral () inMaven {URL "https://repo.spring.io/libs-release"} - } to  + //Add Dependency - Dependencies { theCompile ' org.springframework.boot:spring-boot-starter-web ' *Compile ' org.slf4j:slf4j-api:1.7.12 ' $Compile ' com.google.code.gson:gson:2.3.1 'Panax NotoginsengTestcompile ' junit:junit:4.12 ' - } the  + Task Wrapper (type:wrapper) { Agradleversion = ' 2.4 ' the}

3. Writing the Spring-boot file

//Springboot starting the main function@SpringBootApplication Public classApplication { Public Static voidMain (string[] args) {springapplication.run (application.class, args); }}//Rest-based access interface@RestController Public classHellorcontroller {@RequestMapping (value= "/hello", method =requestmethod.get) PublicUser Getuserhello () {return NewUser ("Tobepro", "Password"); }}

There is also a Pojo class here, it is not written.

To this one of the simplest spring-boot framework is completed. The records of the relatively rough, in the future study in-depth study.

Gradle Creating a Spring-boot Project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.