BeanUtils not works for chain setter

后端 未结 3 960
你的背包
你的背包 2021-01-04 19:25

e.g.

class tester
{
    @Test
    public void testBeanUtils() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException
    {
        S         


        
3条回答
  •  清酒与你
    2021-01-04 20:00

    You can use the FluentPropertyBeanIntrospector implementation:

    "An implementation of the BeanIntrospector interface which can detect write methods for properties used in fluent API scenario."

    https://commons.apache.org/proper/commons-beanutils/apidocs/org/apache/commons/beanutils/FluentPropertyBeanIntrospector.html

    PropertyUtils.addBeanIntrospector(new FluentPropertyBeanIntrospector());
    BeanUtils.setProperty( this.o, "property", "value" );
    

提交回复
热议问题