java - 'java.lang.LinkageError: loader constraint violation:' 重启Springboot项目时出错
问题描述
我有一个简单的Springboot 项目
我在 IntelliJ IDE 中进行了设置:
compiler.automake.allow.when.app.running
在注册表中启用复选框Build project automatically
在编译器设置中启用。
当我更改代码并保存它时,并不总是但经常出现错误:
2018-11-23 05:25:10.544 ERROR 344 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "ru.krivochenko.demo.user.UserService.getNewUser()Lru/krivochenko/demo/user/User;" the class loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @6ce6e730 (instance of org.springframework.boot.devtools.restart.classloader.RestartClassLoader, child of 'app' jdk.internal.loader.ClassLoaders$AppClassLoader) of the current class, ru/krivochenko/demo/MainController, and the class loader 'app' (instance of jdk.internal.loader.ClassLoaders$AppClassLoader) for the method's defining class, ru/krivochenko/demo/user/UserService, have different Class objects for the type ru/krivochenko/demo/user/User used in the signature] with root cause
感谢帮助!
解决方案
由于某种原因,在重建更改类之后,在它真正存在之前有一个时间间隔。我在 application.properties 中使用了一些值,发现结果对我有用:
spring.devtools.restart.poll-interval=3000
spring.devtools.restart.quiet-period=2999
推荐阅读
- c++ - C/C++ 中 assert(false) 的更好替代方案
- ajax - 如何修复 laravel 404 NotFoundHttpException 错误?
- javascript - 是否有 lodash 或其他函数来搜索对象数组的数组以查找匹配的键/值?
- node.js - 更改 Node.js 新 Error 对象的前三行?
- android - 向 Google Play 商店中的现有应用提交更新:“运行 bundletool build-apks 时发生错误”
- javascript - 有没有一种方法可以使用 javascript mslink.sh 创建 lnk 文件
- javascript - 如何显示文档选择器对话框 - Alfresco 6
- android - 类 DescriptorExtractor 在适用于 Android 的 opencv 4.1.0 中不可用
- azure - 需要在电子邮件通知中发送发布测试结果图表
- postgresql - 禁止用户的所有者对该表进行 GRANTing