1、首先定义indexName的赋值类
public class EsIndexChange {
private static String suffix;
public static void setSuffix(String suffix) {
EsIndexChange.suffix = suffix;
}
public static String getSuffix() {
return suffix;
}
}
2、然后直接用在@Document注解里面
@Document(indexName = "testmail_#{ T(com.util.EsIndexChange).getSuffix() }", type = "mail")
public class MailInfo{
@Id
@Field(index = false, store = true, type = FieldType.Text)
private String id;
.......
然后再需要换索引的时候,setSuffix就可以了。
原文:https://blog.csdn.net/duanqiaocanyue2012/article/details/82843309