@Value annotation in java interfaces

I have an interface parent class lets call it IParent here. There are two child classes that implements this interface ChildA and ChildB. ChildA also extends another class OtherClass.

public interface IParent{      @Value("${car.color:blue}")     public final String color = "blue";      public int doSomething(); }   public class ChildA extends OtherClass implements IParent{     public int doSomething();  }   public class ChildB implements IParent{     public int doSomething(); } 

I want to use iParent.color in my application but I want color to be read from a settings file, since the variable is final in an interface it does not work. The reason I cannot move this to the derived classes because I don’t want a type conversion where ever I use the derived classes. Any idea how I can get it to work?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.