I like code to be visually easy to read (subjective, I know). Is there a a way in Spring to take the first form of code
@Autowired
private O1 o1
@Autowired
private O2 o2
@Autowired
private O3 o3
And do something like this:
@Autowired
private O1 o1
private O2 o2
private O3 o3
@Endautowire
I would find the code to be less cluttered. I know I am being trivial and picky, but...
You can use constructor to inject all objects with one annotation:
private O1 o1;
private O2 o2;
private O3 o3;
@Autowired
public ClassA(O1 o1, O2 o2, O3 o3) {
this.o1 = o1;
this.o2 = o2;
this.o3 = o3;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With