Is there an option to insert property on interface field? I tried something like this, but it didn't work.
public interface ServicePathsConfig {
@Value("${default-connection-timeout}")
int DEFAULT_CONNECT_TIMEOUT = 1000;
}
I tried to make default setter with @PostConstruct, same result. Any ideas how can I inject property to interface field?
As a workaround, in some cases you can turn your interface into an abstract class, and then it is possible:
public abstract class ServicePathsConfig {
@Value("${default-connection-timeout:1000}")
protected int defaultConnectTimeout;
public abstract void someMethod();
}
Fun fact about C++: It is what some people from the C++ world call the "Interface Design Pattern", not having interface as a language feature, but having multiple inheritance.
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