给出以下配置:
@Configuration
public class AppConfiguration {
@Bean
Mongo mongo() throws UnknownHostException {
return new Mongo("localhost");
}
@Bean(name = "MovieTemplate")
MongoTemplate beagleTemplate(Mongo mongo) {
return new MongoTemplate(mongo, "MovieDatabase");
}
@Bean(name = "AnotherTemplate")
MongoTemplate tmdbTemplate(Mongo mongo) {
return new MongoTemplate(mongo, "AnotherDatabase");
}
}
我需要一个存储库来访问电影,它看起来有点像这样:
@Repository
public interface MoviesRepository extends
MongoRepository<ProductPages, String> {
... some method declarations to access movies ...
}
是否有注释驱动的方式来告诉存储库使用哪个模板?如果不是,还有什么办法可以解决这个问题?