繁体   English   中英

使用Spring配置文件中的条目作为注释属性的值

[英]Using an entry from the Spring configuration file as value for annotation property

我正在尝试从代码中取出ElasticSearch indexName的名称,并将其拉入配置文件。

@Document(indexName = "test", type = "file")
public class File {
***
}

我遇到的问题是,我不知道您如何将“测试”放入.properties文件中的值中,并在批注中使用它。

您可以使用以下方法执行此操作:

@Document(indexName = "${keyname}", type = "file")

在属性文件中:

keyname=test

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM