value for the annotation attribute must be constant expression

后端 未结 2 1482
囚心锁ツ
囚心锁ツ 2021-01-19 17:27

I have a properties file that I read by spring annotation like this

    @Value(\"${platform}\")
    private String platform;

after I get th

2条回答
  •  广开言路
    2021-01-19 17:54

    The parameter is evaluated in compilation time. So it needs to be final or static final among others (ie Enum).

    I don't know if the @Value annotation allows that. But you can always implement your own annotation. Extending is not possible in Java annotations.

提交回复
热议问题