[已解决]springBoot 中添加 dev-tools后,运行程序报错Unenhance strategy


发生条件:
在pom.xml中增加dev-tools的依赖,程序启动后,调用程序接口报错

问题现象:
-------------------------------------------------------------
Registered concrete types: 5 (approximate size: 630.7 kB)
  [interface java.util.Collection] : ArrayList<Object>
  [interface java.util.Map] : LinkedHashMap<Object, Object>
  [interface java.util.Map$Entry] : MapEntry<Object, Object>
  [interface java.util.Set] : LinkedHashSet<Object>
  [interface java.util.List] : ArrayList<Object>
-------------------------------------------------------------
Resolved strategies: 1 (approximate size: 42,825.6 kB)
{source: AppOrganization, dest: AppOrganizationDTO, in-place:false}: InstantiateAndUseCustomMapperStrategy<AppOrganization, AppOrganizationDTO> {customMapper: ma.glasnost.orika.impl.ReversedMapper@217ff750, unenhancer: ma.glasnost.orika.unenhance.BaseUnenhancer@4203fb3, objectFactory: DefaultConstructorObjectFactory<AppOrganizationDTO>}
-------------------------------------------------------------
Unenhance strategy: ma.glasnost.orika.unenhance.BaseUnenhancer@4203fb3
-----end dump of current state-------------------------------
    at ma.glasnost.orika.impl.ExceptionUtility.newMappingException(ExceptionUtility.java:55)
    at ma.glasnost.orika.impl.MapperFacadeImpl.map(MapperFacadeImpl.java:752)
    at ma.glasnost.orika.impl.MapperFacadeImpl.map(MapperFacadeImpl.java:721)

问题原因:
貌似是orika的bug

解决方案:
(参考https://stackoverflow.com/questions/33324944/orika-classcastexception-in-spring-boot-webapp):
  1. Create a META-INF folder in src/main/resources.
  2. Create spring-devtools.properties file in it.
  3. Add restart.include.orika=/orika-core.*.jar to the file.
  
原文地址:https://www.cnblogs.com/xueluozhangxin/p/8711155.html