Java / Quarkus Interview questions
What is the difference between @Inject and @ConfigProperty in Quarkus?
Both annotations request something be supplied to a field or constructor parameter, but they pull from fundamentally different sources: one resolves a CDI bean, the other resolves a configuration value.
| @Inject | @ConfigProperty |
| Resolves a CDI-managed bean instance. | Resolves a value from application configuration (properties/env vars). |
| Target is another class, e.g. a service or repository. | Target is typically a primitive, String, or simple wrapper type. |
| Requires the target class to be a recognized CDI bean. | Requires a matching key in configuration sources, or a defaultValue. |
| Used for wiring dependencies between components. | Used for injecting externalized settings like a port or timeout. |
They're frequently used together in the same class — injecting a repository bean via @Inject alongside a configured timeout value via @ConfigProperty — since one supplies behavior and the other supplies externalized data that behavior depends on.
More Related questions...