question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Springboot CLI - Hot Reload Not Triggering

See original GitHub issue

Referenced Docs: https://docs.spring.io/spring-boot/docs/2.1.7.RELEASE/gradle-plugin/reference/html/ https://docs.spring.io/spring-boot/docs/2.1.7.RELEASE/reference/html/using-boot-devtools.html https://guides.gradle.org/building-spring-boot-2-projects-with-gradle/

SpringBoot Version: v2.1.7.RELEASE Gradle Version: 5.5.1 OS: Ubuntu 18.04.3 LTS Java Version: 11.0.4

I built the project with command: gradle init --type java-application I ran the project with ./gradlew bootRun

Project runs fine, it’s just the code from: https://guides.gradle.org/building-spring-boot-2-projects-with-gradle/

Upon altering the code in, for example, HelloGradleController.java to return “Hello Gradle!!” there is no detection of file change or hot-reload.

Upon shutting down (Ctrl+C) and executing ./gradlew bootRun the project starts up and the changes are detected when I visit localhost:8080 once again.

bootRun prompt:

> Task :bootRun

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.7.RELEASE)

2019-08-09 11:04:01.080  INFO 4893 --- [  restartedMain] example.App                              : Starting App on ben-VirtualBox with PID 4893 (/home/ben/SpringBootProjects/gradle-spring-boot-project/build/classes/java/main started by ben in /home/ben/SpringBootProjects/gradle-spring-boot-project)
2019-08-09 11:04:01.083  INFO 4893 --- [  restartedMain] example.App                              : No active profile set, falling back to default profiles: default
2019-08-09 11:04:01.177  INFO 4893 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-08-09 11:04:01.178  INFO 4893 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-08-09 11:04:02.806  INFO 4893 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-08-09 11:04:02.856  INFO 4893 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-08-09 11:04:02.856  INFO 4893 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.22]
2019-08-09 11:04:02.996  INFO 4893 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-08-09 11:04:02.996  INFO 4893 --- [  restartedMain] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1818 ms
2019-08-09 11:04:03.272  INFO 4893 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-08-09 11:04:03.478  INFO 4893 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2019-08-09 11:04:03.550  INFO 4893 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-08-09 11:04:03.560  INFO 4893 --- [  restartedMain] example.App                              : Started App in 2.994 seconds (JVM running for 3.488)
<=========----> 75% EXECUTING [9s]
> :bootRun

My build.gradle

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java project to get you started.
 * For more details take a look at the Java Quickstart chapter in the Gradle
 * User Manual available at https://docs.gradle.org/5.5.1/userguide/tutorial_java_projects.html
 */

plugins {
    // Apply the java plugin to add support for Java
    id 'java'

    // Apply the application plugin to add support for building a CLI application
    id 'application'
    
    //https://guides.gradle.org/building-spring-boot-2-projects-with-gradle/
    id 'org.springframework.boot' version '2.1.7.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
}


bootRun {
    sourceResources sourceSets.main
}


repositories {
    // Use jcenter for resolving dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

//https://docs.spring.io/spring-boot/docs/2.1.7.RELEASE/reference/html/using-boot-devtools.html
configurations {
   developmentOnly
   runtimeClasspath {
       extendsFrom developmentOnly
   }
}

dependencies {
    //compile('org.springframework.boot:spring-boot-devtools')
    developmentOnly('org.springframework.boot:spring-boot-devtools')

    // This dependency is used by the application.
    implementation 'com.google.guava:guava:27.1-jre'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'

    //https://guides.gradle.org/building-spring-boot-2-projects-with-gradle/
    implementation 'org.springframework.boot:spring-boot-dependencies:2.1.7.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    components {
        withModule('org.springframework:spring-beans') {
            allVariants {
                withDependencyConstraints {
                    // Need to patch constraints because snakeyaml is an optional dependency
                    it.findAll { it.name == 'snakeyaml' }.each { it.version { strictly '1.19' } }
                }
            }
        }
    }
}

application {
    // Define the main class for the application
    mainClassName = 'example.App'
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TheGitHubGuy1commented, Aug 13, 2019

@snicoll no worries, thanks for your time.

I had an assumption in my mind that spring boot CLI would work like node for example. But that was an assumption and the documentation doesn’t explicitly say otherwise.

I come from a framework that does do auto recompile so it could just be my past experience affecting my expectations.

https://docs.spring.io/spring-boot/docs/2.1.7.RELEASE/gradle-plugin/reference/html/ Section 6.2 in my eyes gives the impression of auto recompile. Perhaps that can be clarified.

This closed ticket can give an indicator of others experiences, if others come along with the same query add a comment or a thumbs up.

0reactions
snicollcommented, Aug 13, 2019

@BenStuart This section is about “resources” (so web templates, css, etc. not code). This is good feedback, I’ve created https://github.com/spring-projects/spring-boot/issues/17851

Read more comments on GitHub >

github_iconTop Results From Across the Web

Live reload not working in Spring boot devtools - Stack Overflow
First open setting.json (ctrl + shift+P) file and define a property there as "java.autobuild.enabled": true. · second open application.properties ...
Read more >
83. Hot swapping - Spring
Due to the default restart exclusions, changes to static resources will not trigger a restart of your application. They will, however, trigger a...
Read more >
How to fix hot reload not working in dev-tools ... - YouTube
This video shows How to fix hot reload not working in dev-tools dependency in SpringBoot || dev-tools in Intellij.
Read more >
Spring Boot auto reload changes using LiveReload and ...
1. Install Spring Boot DevTools · 2. Install LiveReload extension for your browser · 3. What will trigger a browser refresh? · 4....
Read more >
Spring Boot | IntelliJ IDEA Documentation - JetBrains
Enable automatic restart ... Add the spring-boot-devtools module dependency for your project. ... Setting the spring-boot-devtools dependency as ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found