Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropertyUtils.addBeanIntrospector(new FluentPropertyBeanIntrospector()); #185

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wqssyq
Copy link

@wqssyq wqssyq commented Jun 5, 2019

【问题描述】

数据新增时,需要 trim,写了个 通用的 trim 类,
参考 QueryGenerator.java 写的,结果报错:
java.lang.NoSuchMethodException: Property 'xxx' has no setter method in class 'class org.jeecg.modules.xxx.entity.xxx'

【原因如下】
BeanUtils not works for chain setter

https://www.manongdao.com/article-780682.html

【解决方案】
添加
static {
PropertyUtils.addBeanIntrospector(new FluentPropertyBeanIntrospector());
}

【注意】
在 QueryGenerator.java 里也必须添加

static {
	PropertyUtils.addBeanIntrospector(new FluentPropertyBeanIntrospector());
}

查看 PropertyUtils 源码:

public static PropertyDescriptor[] getPropertyDescriptors(final Object bean) {
    return PropertyUtilsBean.getInstance().getPropertyDescriptors(bean);
}

这里用了单例模式: PropertyUtilsBean.getInstance()

【问题描述】

数据新增时,需要 trim,写了个 通用的 trim 类,
参考 QueryGenerator.java 写的,结果报错: 
java.lang.NoSuchMethodException: Property 'xxx' has no setter method in class 'class org.jeecg.modules.xxx.entity.xxx'

【原因如下】
BeanUtils not works for chain setter

https://www.manongdao.com/article-780682.html

【解决方案】
添加
	static {
		PropertyUtils.addBeanIntrospector(new FluentPropertyBeanIntrospector());
	}

【注意】
在 QueryGenerator.java 里也必须添加

	static {
		PropertyUtils.addBeanIntrospector(new FluentPropertyBeanIntrospector());
	}

查看 PropertyUtils 源码:	
	
    public static PropertyDescriptor[] getPropertyDescriptors(final Object bean) {
        return PropertyUtilsBean.getInstance().getPropertyDescriptors(bean);
    }
	
这里用了单例模式: PropertyUtilsBean.getInstance()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant