Spring-Boot-Devtools 不想重新加载进程(没有选择正确的类路径?)

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

我有一个小的 Spring 启动项目(来自 spring-boot-starter)。所有配置,我想使用 Spring-Boot-Devtools 自动重新加载。 当我从我的 git 存储库工作目录启动我的项目 (mvn spring-boot:运行 -X) 时,我可以看到:

maven 日志:

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

没关系,路径看起来不错。 然后是应用日志:

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

类路径为空?可能这就是 Devtools 不想自动重新加载我的应用程序的问题。但是为什么?

当我将项目文件夹(没有其他更改!!!)复制到其他地方时,重新加载工作!

Maven (mvn spring-boot:运行 -X) :

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

及以后:

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/]

为什么会有差异?怎么了 ?在第二种情况下,重新加载有效。

好的,在对项目进行了几分钟的摆弄之后,我发现问题可能出在项目文件夹名称 'spring-boot-starter'(来自 eclipse spring boot creator 的默认项目名称? ) 这就是为什么在不同的文件夹中重新加载有效(项目文件夹名称也不同),在我的 git 存储库下更改项目文件夹名称后,重新加载又开始工作了。

是否有记录'feature'? :)

看起来项目的 DIRECTORY 不应该命名 'spring-boot-....' (它与工件名称或 eclipse 项目名称无关)

Spring Boot 在考虑是否应该自动重启时会忽略某些项目名称。这是 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

您应该重命名您的项目,以便明确它不是 Spring 引导本身的一部分并且符合自动重启的条件。