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反射的時候出現(xiàn)的問題,那么為什么會出現(xiàn),因為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在反射的時候就不會區(qū)分不清是什么屬性。