spring data 4 mongodb 在domain上添加annation,自动创建复合索引时需要使用CompoundIndexes。
例如:
@CompoundIndex(name = "shop_index", def = "{platform : 1, shopId : 1}")
程序也不会有编译错误或者执行错误,但是spring data不会建立任何索引,
下面这样写才会启动时自动建立复合索引。
@CompoundIndexes({
@CompoundIndex(name = "shop_index", def = "{platform : 1, shopId : 1}")
})
spring data 4 mongoDB 自动创建复合索引
猜你喜欢
转载自sonic126.iteye.com/blog/1815366
今日推荐
周排行