eclipsegradlespring-bootspring-loaded

spring boot use springloaded no work in gradle


When i use springloaded in my project. There is a similar question in Spring Boot + Spring-Loaded (IntelliJ, Gradle) According to the document , my build.gradle is :

buildscript{
ext{
    springBootVersion = '1.3.5.RELEASE'
}
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath 'org.springframework:springloaded:1.2.0.RELEASE'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
//apply plugin: 'application'
springBoot {
    backupSource = false
    mainClass = 'com.zhb.app.PortalApplication'
}

jar {
    baseName = 'springBootTest'
    version =  '0.0.1-SNAPSHOT'
}

//applicationDefaultJvmArgs = ['-javaagent:E:\\xgsdk\\commonLib\\springloaded-1.2.5.RELEASE.jar -noverify']

repositories {
    mavenCentral()
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-web",
            "com.alibaba:fastjson:1.2.4",
            "commons-codec:commons-codec:1.5",
            "org.apache.commons:commons-lang3:3.3.2"

    testCompile("org.springframework.boot:spring-boot-starter-test")
}

when i run the application in eclipse. the springloaded is not working.
then i follow the springloaded document, add -javaagent:<pathTo>/springloaded-{VERSION}.jar -noverify to the run configuration Finally it is working well. enter image description here

There are two question arise in my mind.
the first is the springloaded dependency classpath'org.springframework:springloaded:1.2.0.RELEASE' is not necessary.
the second is that is there a way to define the VM argument -javaagent:<pathTo>/springloaded-{VERSION}.jar -noverify in build.gradle.
i see the gradle document. In my build.gradle,the comment code is showing
//apply plugin: 'application' //applicationDefaultJvmArgs = ['-javaagent:E:\\xgsdk\\commonLib\\springloaded-1.2.5.RELEASE.jar -noverify']
but it is not working.


Solution

  • I see that you use spring 1.3.x

    Spring loaded is in the attic: https://spring.io/projects

    You should use DevTools from now on: https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3

    Several options are available (DevTools, Spring loaded, JRebel, etc.)

    DevTools is the recommended Spring way, not the only way.

    From the docs: "There are several options for hot reloading. The recommended approach is to use spring-boot-devtools as it provides additional development-time features such as support for fast application restarts and LiveReload as well as sensible development-time configuration (e.g. template caching).

    Alternatively, running in an IDE (especially with debugging on) is a good way to do development (all modern IDEs allow reloading of static resources and usually also hot-swapping of Java class changes).

    The spring-boot-devtools module includes support for automatic application restarts. Whilst not as fast a technologies such as JRebel or Spring Loaded it’s usually significantly faster than a “cold start”. You should probably give it a try before investigating some of the more complex reload options discussed below."

    Spring loaded is not very active at the moment: https://github.com/spring-projects/spring-loaded/releases hence why it's in the attic on the spring project page.