I am trying to get a simple Spring-Boot application to work with Spring Loaded and Gradle without any success. I have tried the following:
Using Spring-Boot with the bootRun
task simply reloads static resources just fine with a simple F5 in the browser
If I use bootRun
again and change a class through a text editor and the use compileJava
it doesnt work.
If I run it with IntelliJ Application
make a change in an existing controller and use the IntelliJ make
it works only for existing methods. Doesnt update new methods, change of signatures etc.
Using IntelliJ with VM argument:
-javaagent:C:\Users\myuser\.m2\repository\org\springframework\springloaded\1.2.1.RELEASE\springloaded-1.2.1.RELEASE.jar -noverify
Still does nothing.
Ideally, I would like to perform the process through using Gradle only - so I'm IDE independent
Please have a look at the Github project so you can see my sample code: Sample Project
Just perform any changes in the DemoController
Seems the trick was to use the task build bootRun
instead of a simple 'bootRun`.
This is a Gradle build file that also uses the watch plugin with incremental compiles when Java classes change:
buildscript {
ext {
springBootVersion = '1.2.2.RELEASE'
springLoadedVersion = "1.2.1.RELEASE"
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.springframework:springloaded:${springLoadedVersion}")
classpath 'com.bluepapa32:gradle-watch-plugin:0.1.5'
}
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
apply plugin: "java"
apply plugin: "spring-boot"
apply plugin: 'idea'
apply plugin: 'application'
apply plugin: 'com.bluepapa32.watch'
mainClassName = "com.example.my.Application"
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
runtime("org.hsqldb:hsqldb")
}
task wrapper(type: Wrapper) { gradleVersion = '2.3' }
idea {
module {
inheritOutputDirs = false
outputDir = new File("$buildDir/classes/main/")
}
}
compileJava {
//enable compilation in a separate daemon process
options.fork = true
//enable incremental compilation
options.incremental = true
}
watch {
java {
files files('src/main/java')
tasks 'compileJava'
}
}