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

Commits on Jun 5, 2019

  1. Update QueryGenerator.java

    【问题描述】
    
    数据新增时,需要 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()
    wqssyq committed Jun 5, 2019
    Configuration menu
    Copy the full SHA
    c7359b1 View commit details
    Browse the repository at this point in the history
  2. Create TrimUtil.java

    TrimUtil
    wqssyq committed Jun 5, 2019
    Configuration menu
    Copy the full SHA
    c2271eb View commit details
    Browse the repository at this point in the history