spring-boot-devtools doesn't reload dependent modules in multi-module maven project
Asked Answered
W

2

9

Before I start, I'd like to say that I already tried the solution proposed in spring-boot-devtools reload of multi-module maven project changes, which didn't work for me.

Problem:

I have a multi-module Spring Boot project of this sort:

enter image description here

The module launcher has a Maven dependency on module GUI. I launch my Spring Boot application from the main method in launcher.

When I run the application and change any HTML file in GUI module, the spring-boot-devtools dependency doesn't do a live reload of these changes for my running application. Not even manual restart of launcher helps. I need to compile GUI manually and then run launcher again.

What I tried:

  1. I tried defining the spring-boot-devtools dependency first in parent pom.xml, then in GUI module only and then in both at the same time.
  2. I tried adding spring.devtools.restart.additional-paths=../gui in my application.properties file as suggested in spring-boot-devtools reload of multi-module maven project changes. This does indeed trigger the reload (according to the log), but those changes just don't propagate to the jar file of GUI dependency. Also, before I even made this project into multi-module, there was no need for reloading just because of HTML files (nothing is being compiled) and I could see the changes right away.

I use Netbeans GUI if that's of any help. I also tried running the project from command line, with no success. The Maven packaging on all modules is set to jar.

Workbook answered 13/10, 2017 at 10:54 Comment(2)
what happens if you remove relative paths from the equation and only configure spring.devtools.restart.additional-paths= with absolute paths?Proviso
@BrianClozel It works this way. I put in the path is this format: C:\\Users\\Saraph\\path\\to\\gui. However I'd still want to generalize this somehow. While it works for my machine, every single team member would have to reconfigure this.Workbook
W
-4

I have no idea how it happened, but upon one revisit it started working without me knowingly changing anything. It doesn't even require the spring.devtools.restart.additional-path property set.

Could've been a problem of Netbeans IDE perhaps? Then again, it didn't work from command line either. If anyone has any explanation for this, it'd still be grateful as it may prevent this problem from happening in future.

Workbook answered 17/10, 2017 at 20:28 Comment(2)
I'm glad your problem resolved itself, but it's hard to characterize this as an answer.Vivisectionist
@MikePatrick I understand, but I can't offer anything better. The answer is "if this happens to you, try to reload your development environment".Workbook
P
5

The fact that this works when you configure absolute paths in devtools tells me that this is mainly a work directory issue.

So this means that:

  • configured paths should be relative to where you launch the CLI
  • you should configure the same location as a work directory in the run configuration of your IDE (whatever configuration your IDE is using to launch your application should have such an option)

In your case: everything should be relative to your launcher module; this should be as well your work directory in your IDE.

Proviso answered 17/10, 2017 at 20:26 Comment(1)
Please see my own answer. Thanks for help, but I'll have to mark my own as a solution this time.Workbook
W
-4

I have no idea how it happened, but upon one revisit it started working without me knowingly changing anything. It doesn't even require the spring.devtools.restart.additional-path property set.

Could've been a problem of Netbeans IDE perhaps? Then again, it didn't work from command line either. If anyone has any explanation for this, it'd still be grateful as it may prevent this problem from happening in future.

Workbook answered 17/10, 2017 at 20:28 Comment(2)
I'm glad your problem resolved itself, but it's hard to characterize this as an answer.Vivisectionist
@MikePatrick I understand, but I can't offer anything better. The answer is "if this happens to you, try to reload your development environment".Workbook

© 2022 - 2024 — McMap. All rights reserved.