Suppose we have a Class A, and B. inside B’s constructor, not only A is needed, but also some other String / boolean values. e.g
@Componenet(value = "B")
@DependsOn(value = "A")
public class B{
...
}
public B(A a_instance, String name1, String name2, boolean b1){
...
}
I know using annotation. but not knowing exactly, what should be done with those String/boolean values?
Your question isn’t entirely clear. Your B constructor appears to be outside of class B. Aside from that, assuming there are no other constructors, what you have won’t work because Spring will look for a default constructor. I think what you’re asking is what to do if you want to
@Autowiredthat constructor to get String and boolean values in it. If so, you want something like this:In this situation,
@Valueacts somewhat like@Qualifierwould if you had multiple beans of type A.