I have a value in annotation, for which I want to assign a static variable I tried something like this
@Cacheable(value = "#com.test.App.VALUE")
public List someCachableMethod() {
}
After trying this its still same Exception : field or Property cannot be found or null
public class App {
private static String MY_NAME = " XXXX";
public static void main(String[] args) {
ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("#MY_NAME)");
String message = (String) exp.getValue();
System.out.println("---------------->"+message);
}
}
Use the T
operator:
"#{T(com.test.App).VALUE}"
but make the constant public
.
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