|
Answer» Three Annotation-Based Injection Patterns import org.springframework.beans.factory.annotation.Autowired;
PUBLIC CLASS MyClass {
@Autowired
private OtherClass otherClass ;
//Business LOGIC...
}import org.springframework.beans.factory.annotation.Autowired;
public class MyClass {
private OtherClass otherClass ;
@Autowired
public VOID setOtherClass(final OtherClass otherClass) {
this.otherClass = otherClass ;
}
//Business logic...
}public class MyClass {
private final OtherClass anotherBean;
public MyClass(final OtherClass otherClass) {
this.otherClass = otherClass;
}
//Business logic...
}
|