class Foo {
@Setter @Autowired private Bar bar;
}
Spring will use field injection here. Is there currently any way of telling it to use a setter injection?
I don't know if there is a way to do this in Spring, but you could try to achieve exactly the same behaviour with http://projectlombok.org/features/experimental/onX.html
So it will be something like
class Foo {
@Setter(onMethod=@__({@Autowired}))
private Bar bar;
}
Unfortunately, it's quite ugly...
Also, keep in mind feature status - they said it could be removed from lombok in future releases.
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