0

I followed instructions from Spring website to try Spring DevTools and I cannot see the updated changes, even when i refresh my page.

I tried to include dependencies in build Gradle, but still fail. Many answers on Stack Overflow are outdated.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lightz
  • 11
  • 3
  • For Gradle Spring Boot projects, you need to: 1. Add this line to 'dependencies' of build.gradle developmentOnly 'org.springframework.boot:spring-boot-devtools' 2. Right click on project > Gradle > Refresh Gradle Project, for the gradle libraries to link to project 3. Start your Spring Boot app, to see the DevTool changs 4. Edit any .html in IDE, then refresh the page in browser, to see changes – Lightz Jul 13 '23 at 04:24
  • There is far too little information. How are you running the application? Using Gradle? Using your IDE? If the latter which IDE? – M. Deinum Jul 13 '23 at 06:29

1 Answers1

-3

It can be frustrating when you're not able to see the changes reflected in your Spring application while using Spring DevTools. There could be a few reasons why the changes are not being picked up. Here are some troubleshooting steps you can try:

  1. Check if DevTools is properly configured: Make sure that you have correctly added the necessary dependencies for DevTools in your build.gradle file. You should have the following dependency:
implementation 'org.springframework.boot:spring-boot-devtools'

Also, ensure that the DevTools plugin is enabled in your IDE settings. For example, in IntelliJ IDEA, go to Settings > Build, Execution, Deployment > Compiler and check the "Build project automatically" option.

  1. Clean and rebuild your project: Sometimes, existing build artifacts or cached files can interfere with DevTools. Try cleaning your project and rebuilding it from scratch. In IntelliJ IDEA, you can go to Build > Clean Project and then Build > Rebuild Project.
  2. Disable caching: DevTools has a feature called "LiveReload" that uses browser extensions to automatically reload the page when changes are detected. However, browser caching can sometimes prevent the changes from being applied. Try disabling browser caching or clearing your browser cache.
  3. Check the restart strategy: By default, DevTools uses a "restart" strategy which restarts the entire application. This can sometimes cause delays in seeing the changes. You can try changing the strategy to "reload" instead, which only reloads the modified classes. To do this, add the following property to your application.properties file:
spring.devtools.restart.strategy=reload
  1. Check the package structure: Ensure that your classes and resources are located inside the correct package structure. DevTools only monitors changes in certain directories, such as src/main/java and src/main/resources. If your classes or resources are located outside these directories, they may not be detected by DevTools.

If you have tried all of the above and are still not seeing the changes reflected, it may be helpful to share the relevant parts of your build.gradle file and any error messages or warnings you are encountering. This will allow us to provide more specific guidance.

  • 1
    This answer looks like ChatGPT – DavidW Jul 13 '23 at 13:01
  • This answer looks like it was generated by an AI (like ChatGPT), not by an actual human being. You should be aware that [posting AI-generated output is officially **BANNED** on Stack Overflow](https://meta.stackoverflow.com/q/421831). If this answer was indeed generated by an AI, then I strongly suggest you delete it before you get yourself into even bigger trouble: **WE TAKE PLAGIARISM SERIOUSLY HERE.** Please read: [Why posting GPT and ChatGPT generated answers is not currently allowed](https://stackoverflow.com/help/gpt-policy). – tchrist Jul 17 '23 at 02:23