【发布时间】:2019-11-20 07:06:28
【问题描述】:
在我的application.properties 中,我有这样的属性:
myAppContext=something.special
Spring 应用从此文件中读取属性。
我想在类级注释中访问上述属性:
// "contexts" take in an array of string values
@AClassLevelAnnotation(contexts = {"something.special"})
public class Amazing{}
我想使用属性键来访问它,而不是使用该值(属性文件中已经存在),类似这样,它不起作用:
@AClassLevelAnnotation(contexts = {@Value("${myAppContext}")})
public class Amazing{}
关于它如何工作的任何建议?
【问题讨论】:
-
你试过了吗?
contexts = "${myAppContext}" -
是的,它不起作用。它返回
${myAppContext}而不是它的值。
标签: java spring properties annotations properties-file