1

I'm trying to get restart working with Spring Boot DevTools. I have been following the instructions provided here: https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html

I am using gradle and included this in my build.gradle file:

bootJar {
    excludeDevtools = false
}

I create the jar file and run the jar file:

java -jar app.jar

I am able to connect to the running application through Intellij. When I make a change I can see in the Intellij console that the updated classes are uploaded to the running process. And in the logs of the running process, I see the process attempts to restart. However, the process quits and spits out this log:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.example.BootApplication]; nested exception is java.io.FileNotFoundException: class path resource [com/example/ExampleService.class] cannot be opened because it does not exist.

ExampleService is the class I modified.

I attempted to google the heck out of this, but could find nothing. I looked at many tutorials online, but could find nothing.

Has anyone encountered this or has anything I can try, would be much appreciated.

yspotts
  • 73
  • 1
  • 6
  • Pretty certain you must use the Gradle plugin for the Boot specific features to work: `gradle bootRun` – Randy Casburn Feb 01 '19 at 21:28
  • @RandyCasburn thanks! I just tried it with `gradle bootRun` and it works fine like you suggest. But It seems pretty explicit from the above documentation that it should work with an executable jar by including the snippet I provided above. – yspotts Feb 03 '19 at 02:10
  • I didn't look at the docs before, but just did. You should look again at the first "leaf" note. It very clearly states that you are running your app as a packaged app with `java -jar` - hence the tools are turned off. – Randy Casburn Feb 03 '19 at 02:13

1 Answers1

3

The issue is based on how compilation of a file works. When you compile a file, it first deletes the already compiled file and then adds a new one. During this process, file system watcher consider it as two different updates (deletion of file and addition of a new file) if the poll time is too low. And deletion of file triggers deletion of file from the remote application and tries to restart the application without the file you changed and therefore, you get this error.

I was facing the similar problem but solved it by adding following in application.properties

spring.devtools.restart.pollInterval=10s

You can change the pollInterval that suits you