【发布时间】:2016-04-29 15:54:33
【问题描述】:
我有一个使用 Spring Plat from 1.3.3.RELEASE 的 Spring Boot 应用程序。
在我的开发环境中,我在 IntelliJ IDEA 15 中将其作为“Spring Boot Application”类型运行配置启动。最近,我添加了 'org.springframework.boot:spring-boot-devtools' 用于重新加载类,如 https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html 所述。
起初它可以工作,但最近我注意到从 IDEA 重新加载的类停止工作。
经过一番调试,发现LocalDevToolsAutoConfiguration注解了@ConditionalOnInitializedRestarter,这里失败了
return ConditionOutcome.noMatch("Restarter initialized without URLs");.
URL 为空,因为初始化 URL 的 DefaultRestartInitializer 具有以下条件:
return thread.getName().equals("main") && thread.getContextClassLoader()
.getClass().getName().contains("AppClassLoader");
不幸的是,thread.getContextClassLoader().getClass().getName() 为我返回了 URLClassLoader,而不是 AppClassLoader。
现在,我不确定可能出了什么问题以及重新加载器应该如何工作。我的应用程序/IDE 是否使用了错误的类加载器?还是Spring有bug?
【问题讨论】:
标签: spring spring-boot