可以扩展SimpleMongoRepository

时间:2017-07-01 00:18:16

标签: spring-data spring-data-jpa spring-data-mongodb

我当前的spring boot mongo配置如下所示

@Configuration
@EnableMongoRepositories(Constants.SCAN_PACKAGE)
@Import(value = MongoAutoConfiguration.class)
public class MongoDatabaseConfiguration {

    @Bean
    public ValidatingMongoEventListener validatingMongoEventListener() {
        return new ValidatingMongoEventListener(validator());
    }

    @Bean
    public LocalValidatorFactoryBean validator() {
        return new LocalValidatorFactoryBean();
    }
}

现在我想扩展类SimpleMongoRepository,它似乎是MongoRepository的默认实现。我必须执行哪些配置,因此我会选择CustomMongoRepository extends SimpleMongoRepository而不是默认发送的SimpleMongoRepository

1 个答案:

答案 0 :(得分:0)

Reference Documentation

中描述了它

您基本上会扩展SimpleMongoRepository,并将@EnableMongoRepositories注释中的该类指定为repositoryBaseClass