首页 > 解决方案 > 'java.lang.LinkageError: loader constraint violation:' 重启Springboot项目时出错

问题描述

我有一个简单的Springboot 项目

我在 IntelliJ IDE 中进行了设置:

  1. compiler.automake.allow.when.app.running在注册表中启用复选框
  2. 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

完整的堆栈跟踪

感谢帮助!

标签: javaspringspring-boot

解决方案


由于某种原因,在重建更改类之后,在它真正存在之前有一个时间间隔。我在 application.properties 中使用了一些值,发现结果对我有用:

spring.devtools.restart.poll-interval=3000 spring.devtools.restart.quiet-period=2999


推荐阅读