Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring-Boot-Devtools doesn't want to reload process (doesn't pick up proper classpaths?)

I have a small Spring Boot project (from spring-boot-starter). Everything configured, i want to use Spring-Boot-Devtools for automatic reloading. When i launch my project (mvn spring-boot:run -X) from my git repo working dir, i can see:

maven logs:

DEBUG] Classpath for forked process: C:\Users\razor\git\spring-boot-starter\target\classes;........

that's ok, path looks good. and then app logs:

2016-09-21 23:47:59.568 DEBUG 13528 --- [ restartedMain] .b.l.ClasspathLoggingApplicationListener : Application started with classpath: []

classpath empty? probably that's the problem that Devtools doesn't want to automatically reload my app. But why ?

When i copy project folder (no other alterations !!!) to other place, reloading works !

Maven (mvn spring-boot:run -X) :

[DEBUG] Classpath for forked process: C:\Java\workspace_rentit\spring-boot-starter2\target\classes;.....

and later:

2016-09-21 23:40:34.224 DEBUG 4060 --- [ restartedMain] .b.l.ClasspathLoggingApplicationListener : Application started with classpath [file:/C:/Java/workspace_rentit/spring-boot-starter2/target/classes/]

Why are there differences? What's wrong ? in second case, reloading works.

like image 748
razor Avatar asked Sep 22 '16 08:09

razor


2 Answers

Spring Boot ignores certain project names when considering whether or not an automatic restart should occur. This is described in the documentation:

When deciding if an entry on the classpath should trigger a restart when it changes, DevTools automatically ignores projects named spring-boot, spring-boot-devtools, spring-boot-autoconfigure, spring-boot-actuator, and spring-boot-starter

You should rename your project so that it's clear that it's not a part of Spring Boot itself and is eligible for automatic restarts.

like image 168
Andy Wilkinson Avatar answered Sep 22 '22 01:09

Andy Wilkinson


Ok, after fiddling with a project for a few more minutes, i've found that probably the problem is the project folder name 'spring-boot-starter' (default project name from eclipse spring boot creator?) that's why reloading in different folder worked (project folder name was different too), after changing project folder name under my git repo, reloading started to work again.

Is it documented 'feature' ? :)

looks like project's DIRECTORY shouldn't be named 'spring-boot-....' (it's not connected with artifact name or eclipse project name)

like image 37
razor Avatar answered Sep 25 '22 01:09

razor