开发者

Invalid property exception in spring

I am using spring in my application , When i am loading the springApplicationContext to get the beans i am getting the errors

Caused by: org.springframework.beans.InvalidPropertyException: Invalid property "abc"

Even though there is a property abc and the setter for that propert开发者_高级运维y in the bean.

This is a weird error i know , but i can't figure out where is the problem.

Any pointers will be helpful.

Thanks! Pratik


Ensure that the property has both a public setter and getter. In case of an AnyObject property it should look like:

private AnyObject abc;
public AnyObject getAbc() { return abc; }
public void setAbc(AnyObject abc) { this.abc = abc; }

There is however one special case: in case of a boolean property it should look like:

private boolean abc;
public boolean isAbc() { return abc; }
public void setAbc(boolean abc) { this.abc = abc; }

Note the is prefix instead of get.


I remeber the similar question at Spring forums. It was found out that there was a setter signature like

public class MyClass {

    private Aggregated field;

    public MyClass setField(Aggregated field) {
        this.field = field;
    }
}

I.e. the setter's return type was not void.

Anyway, Spring uses standard Instrospector for processing class properties. Try it with your class and check if target property is found.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜