I'm trying to configure one app to use more than 2 data sources. I have seen examples of this using XML config, but cannot find any information for using with JavaConfig.
I have tried referencing the templates from the repository...
I have also referenced the repository from the AppConfig.java where the template is method is...
I'm at a loss as to how to make this work apart from NOT taking advantage of dependency injection. An assistance or pointers as to where to look would be most helpful.
Thanks
I have tried referencing the templates from the repository...
Code:
@Configuration
@EnableMongoRepositories(mongoTemplateRef="adminMongoTemplate")
public interface AdminSettingsRepository extends CrudRepository<SettingsData, String> {
@Query("{ 'project' : ?0 }")
Iterable<SettingsData> findByProject(String username);
}
Code:
@Configuration
@ImportResource("classpath:/security-context.xml")
@EnableMongoRepositories(basePackages="com.xxxxxx.xxxxxx.data.repositories")
public class AppConfig {
public AppConfig() {
}
//Mongo Template Bean for admin DB
public @Bean
MongoTemplate adminMongoTemplate() throws Exception {
return new MongoTemplate(mongoDbFactory("admin"));
}
Thanks