bug宝典JAVA篇 BeanUtils.copyProperties 日期问题
来源:互联网 发布:2016年网络流行词汇 编辑:程序博客网 时间:2024/06/05 16:05
执行BeanUtils.copyProperties(dest, orig);
的时候出现下面的错误,我的代码如下,主要目的是复制对象,但是又不想一个个set,下面的BeanUtilsExtends
是照着copyproperties 谁赋值给谁抄的,实际运用却出现下面的问题
@Transactional(readOnly = false) private boolean createNewRecord(FontalMaintainLog record, Date nextOptDate){ FontalMaintainLog newRecord = new FontalMaintainLog(); BeanUtilsExtends.copyProperties(newRecord, record); newRecord.setId(StringUtil.getUuidString()); newRecord.setOptDate(nextOptDate); return insertSelective(newRecord); }
Caused by: java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.String at com.dzmsoft.framework.base.util.DateConvert.convert(DateConvert.java:9) ~[classes/:na] at org.apache.commons.beanutils.BeanUtilsBean.convert(BeanUtilsBean.java:1078) ~[commons-beanutils-1.8.3.jar:1.8.3] at org.apache.commons.beanutils.BeanUtilsBean.copyProperty(BeanUtilsBean.java:437) ~[commons-beanutils-1.8.3.jar:1.8.3] at org.apache.commons.beanutils.BeanUtilsBean.copyProperties(BeanUtilsBean.java:286) ~[commons-beanutils-1.8.3.jar:1.8.3] at org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java:137) ~[commons-beanutils-1.8.3.jar:1.8.3] at com.dzmsoft.framework.base.util.BeanUtilsExtends.copyProperties(BeanUtilsExtends.java:16) ~[classes/:na] at com.dzmsoft.fontal.base.service.impl.FontalMaintainLogServiceImpl.createNewRecord(FontalMaintainLogServiceImpl.java:253) ~[classes/:na] at com.dzmsoft.fontal.base.service.impl.FontalMaintainLogServiceImpl.genMaintainLogByNoFinish(FontalMaintainLogServiceImpl.java:117) ~[classes/:na] at com.dzmsoft.fontal.base.service.impl.FontalMaintainLogServiceImpl$$FastClassBySpringCGLIB$$735c3ac8.invoke(<generated>) ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) ~[spring-aop-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) ~[spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.2.5.RELEASE.jar:4.2.5.RELEASE] at com.dzmsoft.fontal.base.service.impl.FontalMaintainLogServiceImpl$$EnhancerBySpringCGLIB$$be923a94.genMaintainLogByNoFinish(<generated>) ~[classes/:na] at com.dzmsoft.fontal.base.service.impl.FontalEndProcessServiceImpl.genNextMaintain(FontalEndProcessServiceImpl.java:164) ~[classes/:na] at com.dzmsoft.fontal.base.service.impl.FontalEndProcessServiceImpl.nextOptDate(FontalEndProcessServiceImpl.java:155) ~[classes/:na] at com.dzmsoft.fontal.base.service.impl.FontalEndProcessServiceImpl.checkMaintainlog(FontalEndProcessServiceImpl.java:142) ~[classes/:na] at com.dzmsoft.fontal.base.service.impl.FontalEndProcessServiceImpl.deal(FontalEndProcessServiceImpl.java:81) ~[classes/:na]
debug发现,红色方框内容有问题,本来arg1就是日期类型,转字符串自然就报错了。
稍作调整如下:
0 0
- bug宝典JAVA篇 BeanUtils.copyProperties 日期问题
- bug宝典JAVA篇 tomcat日志日期与linux不一致
- beanUtils.copyProperties
- BeanUtils.copyProperties
- BeanUtils.copyProperties
- BeanUtils.copyProperties()
- BeanUtils.copyProperties
- BeanUtils.copyProperties&&PropertyUtils.copyProperties
- BeanUtils的copyProperties的效率问题
- BeanUtils的copyProperties的效率问题
- BeanUtils.copyProperties出现了问题的原因
- BeanUtils.copyProperties方法遇到null值问题
- BeanUtils.copyProperties方法遇到null值问题
- BeanUtils.copyProperties方法遇到null值问题
- BeanUtils.copyProperties 在copy Integer类型问题
- BeanUtils.copyProperties 复制对象异常问题
- java对象拷贝之BeanUtils.copyProperties() 用法
- java对象拷贝之BeanUtils.copyProperties() 用法
- Android语音播放格式问题
- 【cocos优化】
- 急急急!!!请教一个关于ASP不报错的问题!浪费一下午的时间啊。。。。。。
- bzoj 3489: A simple rmq problem (KD-tree)
- 安卓模拟器配置了摄像头还是显示黑白棋盘
- bug宝典JAVA篇 BeanUtils.copyProperties 日期问题
- Leetcode Add Two Numbers II
- 如何使用ocilib进行oracle8的读取
- Qt学习笔记(1)---QT5利用事件过滤器实现在控件上绘图
- android工程生成jar包
- 地图API和androidSDK版本高了和低版本有没有冲突
- Shared Library Search Paths
- 安卓开源框架android-async-http-master最新版的应该怎么用啊,求大神指导
- 2016总结,真正新的里程碑和新起点