New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Devtools reload seems to lose application properties on first run in Eclipse #20894
Comments
Eclipse is responsible for compiling and copying the files into the location from which Spring Boot reads them. It would appear that DevTools is seeing this location at a point where the Can you please try tuning the file system watcher's configuration. In particular, an increased quiet period may help. |
Many thanks @wilkinsona, this seems to have fixed it. I've tested with: spring.devtools.restart.poll-interval=3s (Default 1s) And it looks to be working now. Interesting now you've pointed me in the direction, when I change a Java object on first load Eclipse does show it's "Building..." progress bar for several seconds. When I change the same Java object again (e.g. by adding a line int i = 1; then removing it), it compiles far quicker, so presumably it does something like recompile the whole project on first start. Have there been any changes in Boot 2.3 that might be relevant to this - I ask because I recently upgraded to Eclipse 2020-03 so it's possible it's something they changed there, in which case I could raise it with them. It doesn't look like FileSystemWatcher has seen any changes. Although the solution you've given me works, it's a bit of a shame to add ~5 seconds to every restart. On a side note, I did read the DevTools documentation you linked to before posting. However, I missed the Configuring File System Watcher section because it comes under Remote Applications, which didn't appear relevant to me. Possibly this could be tweaked to make it clearer that these settings are relevant for locally run applications as well. |
A bit more info. I set a breakpoint in FileSystemWatcher to look at the changeSet that it's identified. Interestingly, you can see it's picked up not just the Java object I changed, but also the .properties files. I'm not sure why this is happening - will try to investigate further to see if they're being rewritten by Boot or genuinely changed by Eclipse. |
Yeah, that section's in the wrong place. I didn't notice when I linked to it earlier as I searched for the property name and then linked to the section without spotting the wider context. I've opened an issue to relocate it.
Boot doesn't rewrite anything. It relies entirely on the IDE to do so as you make changes.
We haven't changed anything in this area as far as I can recall and the git history tells the same story. I would guess that the change in behaviour is due to something in Eclipse 2020-03. It would be interesting to know what behaviour you see with 2020-03 and Boot 2.2.x. |
I've just managed to reproduce this in Boot 2.2.6, so it's not a new issue. Apologies, I should have taken into account the Eclipse upgrade as well (had to upgrade to Eclipse 2020-03 at the same time as Boot 2.3 to get Java 14 support, which I now see is backported to 2.2.6). I will have a dig around Eclipse to try and find out what's changed there, and if they're doing something funny will raise it with them. Thanks for the rapid investigation on this. |
Thanks for the follow-up. |
Spring Boot 2.3 M3 & M4
My application previously had no issues on Boot 2.1 or 2.2. Since using the Boot milestones, I intermittently see the below issue when making a change to a Java object that triggers a reload. I'm using Eclipse 2020-03 (with the Java 14 patch) with Build Automatically on.
I have a suspicion that Boot is losing application.properties during the reload, because a) if the datasource URL wasn't defined as it complains the app wouldn't be able to start the first time (before the object change), b) in the log below, the Boot ascii art banner appears, yet I have spring.main.banner-mode=off in my application.properties and c) because I also get a tonne of messages about Spring Data Redis repository scanning, and I have spring.data.redis.repositories.enabled=false.
I'm running an application.properties file with most of my configuration, and an application-dev.properties file with some local overrides. At the start log for both the initial and reload startup, I do see "The following profiles are active: dev" as I expect.
For a final bit of weirdness, sometimes after the failed startup it then immediately tries to reload again, and sometimes succeeds, but sometimes doesn't (will try and capture this more).
Attached is my startup log during an occurrence of this.
Boot-Log.txt
It appears to only happen the first time I've started Eclipse - stopping the process and then starting again seems to prevent it. However I'm not sure why Eclipse would be relevant to Boot finding it's properties. My Eclipse debug profile applies -Dspring.profiles.active=dev.
The text was updated successfully, but these errors were encountered: