0

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.

Community
  • 1
  • 1
Edward
  • 1,239
  • 13
  • 20

1 Answers1

1

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.

JohanB
  • 2,068
  • 1
  • 15
  • 15
  • thank you. Do you mean that there is no way to use spring load in my project that use gradle and spring-boot?But why the Spring Boot Reference Guide include the content that configure spring load? – Edward Jul 04 '16 at 10:00
  • Several options are available (DevTools, Spring loaded, JRebel, etc.) DevTools is the recommended Spring way, not the only way. – JohanB Jul 04 '16 at 11:57
  • yes,i wish that the Spring loaded will be useful in the future. – Edward Jul 04 '16 at 12:27
  • I try `spring-boot-devtools` and not very happy with it. It rebuilds your application in background at every small change (mostly in the middle of refactoring) with un-compiled code. Spring Loaded give you full control at reloading. – Grigory Kislin Feb 25 '17 at 15:14