3

Having the following code:

public class Constants {
    public static final String X = "-";
}

And in another class

@Value("${some.property:Constants.X")
private String separator;

How can I achieve this? Constant property is not being loaded

1 Answer 1

4

You need to use the T operator with the actual package name where your Constants class is located like below

@Value("#{T(your.package.Constants).X}")
private String separator;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.