0

I'm reading the Spring boot reference guide about the developer tools, and it mentions the following:

As DevTools monitors classpath resources, the only way to trigger a restart is to update the classpath. The way in which you cause the classpath to be updated depends on the IDE that you are using. In Eclipse, saving a modified file will cause the classpath to be updated and trigger a restart. In IntelliJ IDEA, building the project (Build → Make Project) will have the same effect.

I'm confused, what does "update the classpath" mean? More precisely:

  • If I modify a file within my IDE, it doesn't appear to update the classpath, is this correct?
  • If I click "Build" in IntelliJ, it does appear to update the classpath, but what exactly did the IDE just do?
g00glen00b
  • 41,995
  • 13
  • 95
  • 133
Shuai Li
  • 2,426
  • 4
  • 24
  • 43

1 Answers1

1

To be clear, the classpath specifies the location (path) of user defined classes in a project. Normally, a Spring Boot application needs be be manually restarted when changing a class (a file) to see the changes in action.

As you mentioned, the spring-boot-devtools provide an Automatic Restart:

Applications that use spring-boot-devtools automatically restart whenever files on the classpath change. This can be a useful feature when working in an IDE, as it gives a very fast feedback loop for code changes. By default, any entry on the classpath that points to a folder is monitored for changes. Note that certain resources, such as static assets and view templates, do not need to restart the application.

As DevTools monitors classpath resources, the only way to trigger a restart is to update the classpath. The way in which you cause the classpath to be updated depends on the IDE that you are using. In Eclipse, saving a modified file causes the classpath to be updated and triggers a restart. In IntelliJ IDEA, building the project (Build -> Build Project) has the same effect.

Meaning, with IntelliJ, when building the project (and thereby updating the classpath), the dev-tools will trigger a restart of the application. More easily, one can also set IntelliJ to build automatically and activate compiler.automake.allow.when.app.running (here is how).

Community
  • 1
  • 1
dersvenhesse
  • 6,276
  • 2
  • 32
  • 53