Guest User

Untitled

a guest
Jan 9th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. <context:component-scan base-package="com.plantronics.platform.data,com.plantronics.platform.common"/>
  2. </beans>
  3.  
  4. **EEGRepository.java**
  5. @Repository
  6. @RealtimeMongoRepositorySupport
  7. public interface EEGDatasetRepository extends RealtimeMongoRepository<CsEEGDataset, String> {
  8.  
  9. }
  10.  
  11. @NoRepositoryBean
  12. public interface RealtimeMongoRepository<T, ID extends Serializable> extends GenericMongoRepository<T,ID> {
  13.  
  14. }
  15.  
  16. @Configuration
  17. @ComponentScan
  18. @EnableMongoRepositories(basePackages = {"com.plantronics.platform.data.repository.mongodb.support","com.plantronics.platform.data.repository.mongodb"},
  19. repositoryFactoryBeanClass = RealtimeMongoRepositoryFactoryBean.class, mongoTemplateRef = "realtimeMongoTemplate",
  20. includeFilters = {@ComponentScan.Filter(value = RealtimeMongoRepositorySupport.class, type = FilterType.ANNOTATION)})
  21. @PropertySource("classpath:application.properties")
  22. public class RealtimeMongoConfiguration {
  23.  
  24. private static final Logger log = LoggerFactory.getLogger(RealtimeMongoConfiguration.class);
  25.  
  26. private static MongoClient mongoClient = null;
  27. private static String dbName;
  28. private static String username;
  29. private static String password;
  30. private static String userSource;
  31. private static String[] noSQLDataSourceURLS;
  32. private static Integer[] noSQLDataSourcePorts;
  33. @Inject
  34. private PropertyService propertyService;
  35.  
  36. @Autowired
  37. Environment env;
  38.  
  39. @Bean(name = "realtimeMongo")
  40. public MongoClient mongo() throws Exception {
  41. dbName = propertyService.getNoSQLRealtimeDBName();
  42. username= propertyService.getnoSQLDataSourceUserName();
  43. password = propertyService.getnoSQLDataSourcePassword();
  44. userSource = propertyService.getnoSQLDataSourceUserName();
  45. noSQLDataSourceURLS = propertyService.getnoSQLDataSourceURLS();
  46. noSQLDataSourcePorts = propertyService.getnoSQLDataSourcePorts();
  47. List<ServerAddress> seeds = getNoSQLServerAddresses();
  48. log.info("Initializing realtime mongo config DbName: {} DbSource URL : {} DbPort: {} ",dbName,noSQLDataSourceURLS,noSQLDataSourcePorts);
  49. return MongoClientUtils.getMongoClient(mongoClient, dbName, seeds, username, password, userSource);
  50.  
  51. }
  52.  
  53. @Target({ElementType.TYPE})
  54. @Retention(RetentionPolicy.RUNTIME)
  55. public @interface RealtimeMongoRepositorySupport {
  56.  
  57. }
  58.  
  59. public static void main(String[] str) throws Exception {
  60. Config config=new Config();
  61. if(config.containsKey(Constants.APPLICATION_PROPERTY_FILE_NAME)){
  62. System.setProperty(Constants.APPLICATION_PROPERTY_FILE_NAME,(String)config.get(Constants.APPLICATION_PROPERTY_FILE_NAME));
  63. }
  64. //Build topology
  65. // open/read the application context file
  66. ApplicationContext context = new ClassPathXmlApplicationContext("test-data-spring-context.xml");
  67. TestQuickDisconnectTopology myTopology = new TestQuickDisconnectTopology(context);
  68. myTopology.buildAndSubmit();
  69. }
  70.  
  71. 22:08:03.712 [cluster-ClusterId{value='5c358fc23ebec46ed661c194', description='null'}-localhost:27017] DEBUG org.mongodb.driver.connection - Closing connection connectionId{localValue:1, serverValue:47}
  72. 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: {}
  73. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
  74. at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
Add Comment
Please, Sign In to add comment