Skip to content

Field injection in quarkus #38474

Answered by Ladicek
BrianH85 asked this question in Q&A
Jan 30, 2024 · 3 comments · 7 replies
Discussion options

You must be logged in to vote

The concerns in the linked article generally apply to all full-featured dependency injection containers, including CDI. From a purist perspective, constructor injection should obviously be preferred to field injection. On the other hand, field injection is immensely pragmatic (what's the point of writing a constructor that just assigns its parameters to fields?). Specifically when it comes to testing and mocking, Quarkus has multiple tools that make testing a breeze even in presence of field injection (see https://quarkus.io/guides/getting-started-testing).

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@manovotn
Comment options

@Ladicek
Comment options

@mkouba
Comment options

@edeandrea
Comment options

Answer selected by cescoffier
Comment options

You must be logged in to vote
3 replies
@edeandrea
Comment options

@Chealer
Comment options

@mkouba
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area/arc Issue related to ARC (dependency injection)
6 participants