MongoDB @CompoundIndexes 不起作用,没效果
楔子
springMongoDB 自动创建索引不生效,
使用spring-boot-starter-parent
版本是2.3.0.RELEASE
查看官网发现如下:Automatic index creation is turned OFF by default as of version 3.0.
https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mapping.index-creation
启用 索引自动创建
索引注释使用
@Document
@CompoundIndex(name = "age_idx", def = "{'lastName': 1, 'age': -1}")
public class Personss {
@Id
private ObjectId id;
private Integer age;
private String firstName;
private String lastName;
//get set
)
还没有评论,来说两句吧...