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內(nèi)部在進行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ū)分不清是什么屬性羹铅。