Spring Boot Gradle
※ This is legacy way. If you use gradle plugin in STS we can create STS Project with gradle
New -> Spring Starter Project : You can select gradle or maven from list
Spring Boot Gradle with Eclipse
I would like to use gradle and eclipse to develop Spring Boot Application
This is to make development environment.
The goal is to create program on Eclipse and debug as Spring Boot Application
IDE : Spring Tool Suite
Gradle : Gradle 2.9
OS : Mac OS X EI Capitan
Steps
- Install STS
- Install gradle in Mac
- Install Gradle IDE plugin in Eclipse
- Create build.gradle
- Create eclipse project and import
- Debug setting
Install Gradle
In Mac OS X, brew is the simplest way.
brew install gradle
Install Gradle IDE plugin in Eclipse
From Eclipse Market Place “Help” -> “Eclipse marketplace”
Search by Gradle, you can see Gradle IDE plugin
Create build.gradle
Prepare project root directory and create build.gradle on this project root.
mkdir BootSample cd BootSample
build.gradle
buildscript { repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE") } } apply plugin: "java" apply plugin: "spring-boot" apply plugin: "eclipse" eclipse { classpath { containers "org.springsource.ide.eclipse.gradle.classpathcontainer" } } jar { baseName = "BootSample" version = "0.0.1-SNAPSHOT" } repositories { mavenCentral() } dependencies { compile("org.springframework.boot:spring-boot-starter-web") testCompile("org.springframework.boot:spring-boot-starter-test") }
Create main source directory and project
mkdir -p src/main/java mkdir -p src/test/java gradle eclipse
Project files are done.
Import
You can import this project into Eclipse using “Existing Project”
After importing, “Project right click” -> “Configure” -> “Convert to Gradle Project”
Build
Run following command on your project root
gradle build
Debug from Eclipse
“Run” -> “Debug Configuration” -> Spring Boot App
Set Project, Main type