发生条件:
在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: [email protected], unenhancer: [email protected], objectFactory: DefaultConstructorObjectFactory<AppOrganizationDTO>} ------------------------------------------------------------- Unenhance strategy: [email protected] -----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):
- Create a
META-INF
folder insrc/main/resources
. - Create
spring-devtools.properties
file in it. - Add
restart.include.orika=/orika-core.*\.jar
to the file.