'Grails 4 hot swap / recompile

Im using: Intellij grailsVersion: 4.0.3 gorm.version: 7.0.4.RELEASE

I just get: Testcontroller.groovy changed, recompiling...

But my code isn't hot deployed. With Grails 3 everything worked fine.

What can I do so that the Controllers in Grails 4 and Spring Boot 2 get hot deployed?



Solution 1:[1]

You may use spring-loaded (project has been idle for years but still works) or JRebel for "hot" reloads.

To enable:

build.gradle

dependencies {
    // Remove dev-tools from classpath
    // developmentOnly("org.springframework.boot:spring-boot-devtools") 
    agent "org.springframework:springloaded:1.2.8.RELEASE"
    // (Optional) Native OSX file watcher
    runtimeOnly "io.methvin:directory-watcher:0.9.6"
    //...
}

See: https://github.com/grails/grails-core/pull/11441

Solution 2:[2]

well solved forgot in build.gradle:

    developmentOnly("org.springframework.boot:spring-boot-devtools")

It's very slow compared to the old Spring boot but works as indeed.

Solution 3:[3]

We found a solution for grails 4.0.13 similar to @erichelgeson

you found it here: https://github.com/grails/grails-core/issues/11649#issuecomment-1085910706

bootRun {
    jvmArgs(
        // javaagent: see
        // - https://github.com/grails/grails-core/issues/11649
        // - https://github.com/spring-projects/spring-loaded
        // - find the jar here: https://repo.spring.io/ui/repos/tree/General/libs-snapshot-local/org/springframework/springloaded
        "-javaagent:libs/springloaded-1.3.0.BUILD-20210404.024037-2.jar",
        // ...
}

Here the links from the comment block:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 erichelgeson
Solution 2 Lastone
Solution 3 Dirk27