value for the annotation attribute must be constant expression

后端 未结 2 1481
囚心锁ツ
囚心锁ツ 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:35

    You can't access platform directly in the @Value expression, but you can use Spring Expression Language to accomplish your end goal.

    @Value("${platform}")
    private String platform;
    
    @Value("#{'Url.'.concat(${platform}).concat('.ws')}")
    private String url;
    

提交回复
热议问题