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

微笑、不失礼 提交于 2019-12-21 11:22:25

问题


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.


回答1:


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.




回答2:


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)



来源:https://stackoverflow.com/questions/39634422/spring-boot-devtools-doesnt-want-to-reload-process-doesnt-pick-up-proper-clas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!