Tuesday, March 4, 2014

spring constructor injection

Lets take two classes parent class and children class.
Parent class want's children object within itself.

Class Children {
public helloChildren (){
System.out.orintln ("hello children");
}
}


Class Parent {
private Children children;
@autowired
public Parent (Children children){
this.children=children;
}
public void helloParent (){
System.out.println ("hello parent");
children.helloChildren ();
}
}

Its done threw annotation. 

1 comment:

  1. Hi, after reading this awesome piece of writing i am as well delighted to share my familiarity here with colleagues.

    Curso java

    ReplyDelete