How have a bean injected by default if none else is available through the annotation @LookupIfProperty on Red Hat build of Quarkus?
Issue
Is there a way to have a bean injected by default if none else is available through the annotation @LookupIfProperty?
This is the situation, we have the apllication.properties
country-name=SomethingThatDoesntExists
The ClassThatUsesTheService.java
is implemented as:
@Inject
Instance<ServiceName> serviceNameInstances;
ServiceName ServiceName;
@PostConstruct
void init() {
ServiceName = serviceNameInstances.get(); // EXCEPTION because there is no available bean and no default.
}
The services classes:
@ApplicationScoped
@LookupIfProperty(name = "country", stringValue = "FR")
public class ServiceNameFrenchCountry implements ServiceName {}
@ApplicationScoped
@LookupIfProperty(name = "country", stringValue = "IT")
public class ServiceNameItalianCountry implements ServiceName {}
How can the Italian service be the default?
Environment
- Red Hat build of Quarkus
- 2.x
- 3.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.