A dozer map exception related to Spring boot devtools

瘦欲@ 提交于 2019-11-30 20:18:14

By default, any open project in your IDE will be loaded using the “restart” classloader, and any regular .jar file will be loaded using the “base” classloader. If you work on a multi-module project, and not each module is imported into your IDE, you may need to customize things. To do this you can create a META-INF/spring-devtools.properties file.

The spring-devtools.properties file can contain restart.exclude. and restart.include. prefixed properties. The include elements are items that should be pulled-up into the “restart” classloader, and the exclude elements are items that should be pushed down into the “base” classloader. The value of the property is a regex pattern that will be applied to the classpath.

My Solution: put META-INF/spring-devtools.properties inside resources folder, and add this content

restart.include.dozer=/dozer-5.5.1.jar

Please see : http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-devtools-customizing-classload

You are using two different ClassLoader here. An identical Class loaded with two different ClassLoader is considered as two different Class by the JVM.

The solution to fix this is simple : Use an Interface.

Interfaces are able to abstract this problem, and you can interchange the object they implement between ClassLoaders without limitation, as long as you don't reference the implementation directly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!