Hi All,
I started learning spring from Spring reference 3.0 and i wanted to try how to instantiate inner bean:
Here is my code:
package com.springexample;
public class ExampleBean {
private String samplePropertyExampleBean;
public void setSamplePropertyExampleBean(String samplePropertyExampleBean) {
this.samplePropertyExampleBean = samplePropertyExampleBean;
}
public String getSamplePropertyExampleBean() {
return samplePropertyExampleBean;
}
class InnerBean{
private String sampleProperty;
public void setSampleProperty(String sampleProperty) {
this.sampleProperty = sampleProperty;
}
public String getSampleProperty() {
return sampleProperty;
}
}
}
And my config file is:
When i am trying to retrieve the bean InnerBean i am getting the following error:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'InnerBean' defined in class path resource [spring-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.springexample.ExampleBean$InnerBean]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.springexample.ExampleBean$InnerBean.()
What could be the problem? I tried adding no-argument constructor in the InnerBean still i am getting error..
Can any one help me?