Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <context:component-scan base-package="com.plantronics.platform.data,com.plantronics.platform.common"/>
- </beans>
- **EEGRepository.java**
- @Repository
- @RealtimeMongoRepositorySupport
- public interface EEGDatasetRepository extends RealtimeMongoRepository<CsEEGDataset, String> {
- }
- @NoRepositoryBean
- public interface RealtimeMongoRepository<T, ID extends Serializable> extends GenericMongoRepository<T,ID> {
- }
- @Configuration
- @ComponentScan
- @EnableMongoRepositories(basePackages = {"com.plantronics.platform.data.repository.mongodb.support","com.plantronics.platform.data.repository.mongodb"},
- repositoryFactoryBeanClass = RealtimeMongoRepositoryFactoryBean.class, mongoTemplateRef = "realtimeMongoTemplate",
- includeFilters = {@ComponentScan.Filter(value = RealtimeMongoRepositorySupport.class, type = FilterType.ANNOTATION)})
- @PropertySource("classpath:application.properties")
- public class RealtimeMongoConfiguration {
- private static final Logger log = LoggerFactory.getLogger(RealtimeMongoConfiguration.class);
- private static MongoClient mongoClient = null;
- private static String dbName;
- private static String username;
- private static String password;
- private static String userSource;
- private static String[] noSQLDataSourceURLS;
- private static Integer[] noSQLDataSourcePorts;
- @Inject
- private PropertyService propertyService;
- @Autowired
- Environment env;
- @Bean(name = "realtimeMongo")
- public MongoClient mongo() throws Exception {
- dbName = propertyService.getNoSQLRealtimeDBName();
- username= propertyService.getnoSQLDataSourceUserName();
- password = propertyService.getnoSQLDataSourcePassword();
- userSource = propertyService.getnoSQLDataSourceUserName();
- noSQLDataSourceURLS = propertyService.getnoSQLDataSourceURLS();
- noSQLDataSourcePorts = propertyService.getnoSQLDataSourcePorts();
- List<ServerAddress> seeds = getNoSQLServerAddresses();
- log.info("Initializing realtime mongo config DbName: {} DbSource URL : {} DbPort: {} ",dbName,noSQLDataSourceURLS,noSQLDataSourcePorts);
- return MongoClientUtils.getMongoClient(mongoClient, dbName, seeds, username, password, userSource);
- }
- @Target({ElementType.TYPE})
- @Retention(RetentionPolicy.RUNTIME)
- public @interface RealtimeMongoRepositorySupport {
- }
- public static void main(String[] str) throws Exception {
- Config config=new Config();
- if(config.containsKey(Constants.APPLICATION_PROPERTY_FILE_NAME)){
- System.setProperty(Constants.APPLICATION_PROPERTY_FILE_NAME,(String)config.get(Constants.APPLICATION_PROPERTY_FILE_NAME));
- }
- //Build topology
- // open/read the application context file
- ApplicationContext context = new ClassPathXmlApplicationContext("test-data-spring-context.xml");
- TestQuickDisconnectTopology myTopology = new TestQuickDisconnectTopology(context);
- myTopology.buildAndSubmit();
- }
- 22:08:03.712 [cluster-ClusterId{value='5c358fc23ebec46ed661c194', description='null'}-localhost:27017] DEBUG org.mongodb.driver.connection - Closing connection connectionId{localValue:1, serverValue:47}
- Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'EEGDatasetRepository': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.Class<org.springframework.data.mongodb.repository.MongoRepository<?, ?>>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
- at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
- at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
Add Comment
Please, Sign In to add comment