【问题标题】:Spring Boot DevTools not initialized because of the URLClassLoader with IntelliJ IDEA由于带有 IntelliJ IDEA 的 URLClassLoader,Spring Boot DevTools 未初始化
【发布时间】: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


【解决方案1】:

我终于找到了“错误”类加载器的原因。

这是 IntelliJ IDEA 中的“动态类路径”功能: <property name="dynamic.classpath" value="true" /> 如果它被禁用,则重新加载器已正确初始化。

【讨论】:

  • 重启程序应该有哪些正确的 URL?我的是空的(并且重新启动没有开始)。使用 URL [] 启动应用程序 xx.demo.starter.StarterApplication
猜你喜欢
  • 1970-01-01
  • 2021-10-28
  • 1970-01-01
  • 1970-01-01
  • 2018-05-29
  • 2020-10-01
  • 2019-01-04
  • 2020-12-14
  • 2015-07-29
相关资源
最近更新 更多