Illegal overloaded getter method with ambiguous type for property

简介: 版权声明:欢迎转载,请注明沉默王二原创。 https://blog.csdn.net/qing_gee/article/details/44307827 Exception in thread "main" org.
版权声明:欢迎转载,请注明沉默王二原创。 https://blog.csdn.net/qing_gee/article/details/44307827
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在反射的时候就不会区分不清是什么属性。

相关文章
|
7天前
|
Java 数据库
JPA IllegalArgumentException occurred while calling setter for property问题件解决
JPA IllegalArgumentException occurred while calling setter for property问题件解决
|
12月前
|
Java 数据库连接 Redis
Bean method ‘redisConnectionFactory‘ not loaded because @ConditionalOnClass did not find required c
Bean method ‘redisConnectionFactory‘ not loaded because @ConditionalOnClass did not find required c
81 0
|
Java Apache Spring
解决required a single bean, but 2 were found问题
背景:springboot整合shiro中自定义Realm时出现 错误描述 Parameter 0 of method getDefaultWebSecurityManager in cn.ken.springboot_shiro.config.ShiroConfig required a single bean, but 2 were foun
成功解决AttributeError: ‘PathCollection‘ object has no property ‘n_levels‘
成功解决AttributeError: ‘PathCollection‘ object has no property ‘n_levels‘
|
SQL Java 数据库连接
attempted to return null from a method with a primitive return type
attempted to return null from a method with a primitive return type
147 0
错误代码: 1364 Field ‘password‘ doesn‘t have a default value
错误代码: 1364 Field ‘password‘ doesn‘t have a default value
解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
308 0
When will the reference ATTRIBUTE_REF of an BOL entity be cleared
When will the reference ATTRIBUTE_REF of an BOL entity be cleared
111 0
When will the reference ATTRIBUTE_REF of an BOL entity be cleared