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