码迷,mamicode.com
首页 > 其他好文 > 详细

Illegal overloaded getter method with ambiguous type for propert错误解决

时间:2015-03-16 17:55:06      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:overloaded   getter   ambiguous   property   解决   

前言:如题,当出现了
Exception in thread "main" org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Illegal overloaded getter method with ambiguous type for property tradeType in class class com.honzh.biz.database.entity.OrderBase.  This breaks the JavaBeans specification and can cause unpredicatble results.

这种错误的时候,该怎么办?

解决办法:

以上问题是因为mybatis内部在进行Java反射的时候出现的问题,那么为什么会出现,因为Java会把Boolean类型的getter方法默认为is打头的或者是get打头的,如

public boolean isTradeType() {
		
	}
	
	public boolean getTradeType() {
		
	}
以上两种方法,Java都会认为是bean的属性封装,那么在反射的时候,Java就不知道该get哪个tradeType了,如果解决呢,如果你的类中有
public Integer getTradeType() {
		return tradeType;
	}
	
	public boolean isTradeType() {
		if (StringUtils.isEmpty(getTradeType()) || (!isBuy() && isSale())) {
			return false;
		}
		return true;
	}
类似以上的方法存在,那么就要注意了,把boolean 的isTradeType方法重命名一下,如换成typeOfTradeType这样就好了,Java在反射的时候就不会区分不清是什么属性。

Illegal overloaded getter method with ambiguous type for propert错误解决

标签:overloaded   getter   ambiguous   property   解决   

原文地址:http://blog.csdn.net/qing_gee/article/details/44307827

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!