我有一个简单的Springboot project
我在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
感谢帮助!
答案 0 :(得分:1)
由于某种原因,在重建更改的类后,在它真正存在之前会有时间间隔。 我在application.properties中使用了一些值,发现结果对我有用:
spring.devtools.restart.poll-interval=3000
spring.devtools.restart.quiet-period=2999