I want to inject properties that have the same names but different prefixes in the application.properties file. For example :
application.properties :
greeting.message = hello
bye.message = bye
For this, the documentation suggests the following usage:
@ConfigProperties(prefix = "greeting")
public class GreetingConfiguration {
@Size(min = 20)
public String message;
}
@ApplicationScoped
public class SomeBean {
@Inject
GreetingConfiguration greetingConfiguration;
@ConfigPrefix("bye")
GreetingConfiguration byeConfiguration;
}
This way I can call greetingConfiguration.message and byeConfiguration message using the same variable (message).
But it's use is not recommended because @ConfigProperties and @ConfigPrefix annotations are deprecated.
It is recommended to use @ConfigMapping instead.
Likewise, How can I use different prefixes and properties with the same name without creating more than one variable (ex :- message) on the java side?