Unable to create Innerbean using Spring - BeanInstantiationException No default constructor found

I started learning spring from spring reference 3.0, and I wanted to try how to create an instance of 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 configuration file:

 

When I try to extract an InnerBean bean, I get the following error:

"main" org.springframework.beans.factory.BeanCreationException: bean "InnerBean", [spring -config.xml]: bean ; - org.springframework.beans.BeanInstantiationException: bean class [com.springexample.ExampleBean $InnerBean]: ; - java.lang.NoSuchMethodException: com.springexample.ExampleBean $InnerBean.()

? InnerBean, .

- ?

+5
2

Java - no-arg. 1 - .

, <constructor-arg> bean ExampleBean

, , . - , , static. . . spring beans, Java .

+21

XML Spring, , .

, InnerBean . , ExampleBean. ( new InnerBean() Java, .)

InnerBean ExampleBean, InnerBean. , Spring. InnerBean (.. ).

. Java, .

+1

All Articles