Guest User

Untitled

a guest
Jan 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. package com.agiletunes.security;
  2.  
  3. import javax.sql.DataSource;
  4.  
  5. import org.springframework.boot.context.properties.ConfigurationProperties;
  6. import org.springframework.boot.jdbc.DataSourceBuilder;
  7. import org.springframework.context.annotation.Bean;
  8. import org.springframework.context.annotation.Configuration;
  9. import org.springframework.context.annotation.Primary;
  10.  
  11. @Configuration
  12. public class MultipleDbConfiguration {
  13.  
  14. /*
  15. * Persistence of com.agiletunes.security
  16. */
  17. @Bean
  18. @Primary
  19. @ConfigurationProperties(prefix="security.datasource")
  20. public DataSource primaryDataSource() {
  21. return DataSourceBuilder.create().build();
  22. }
  23.  
  24. /*
  25. *
  26. * Persistence of com.agiletunes.domain.organization
  27. */
  28. @Bean
  29. @ConfigurationProperties(prefix="spring.datasource")
  30. public DataSource secondaryDataSource() {
  31. return DataSourceBuilder.create().build();
  32. }
  33. }
  34.  
  35. # Employee database
  36. spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  37. spring.datasource.jdbcUrl=jdbc:mysql://127.0.0.1/agiletunesdb?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&characterSetResults=utf-8
  38. spring.datasource.username=[aUsername]
  39. spring.datasource.password=[aPassword]
  40.  
  41. # Account database
  42. security.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  43. security.datasource.jdbcUrl=jdbc:mysql://127.0.0.1/authenticationdb?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&characterSetResults=utf-8
  44. security.datasource.username=[aUsername]
  45. security.datasource.password=[aPassword]
  46.  
  47. # create db schema
  48. spring.jpa.hibernate.ddl-auto=create
  49. #spring.jpa.hibernate.ddl-auto=update
  50.  
  51. # Naming strategy
  52. spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
  53.  
  54. # The SQL dialect makes Hibernate generate better SQL for the chosen database
  55. spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
  56.  
  57. Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.agiletunes.domain.organization.OrganizationService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  58. at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1506)
  59. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101)
  60. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)
  61. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:581)
  62. ... 21 more
  63.  
  64. package com.agiletunes.security.server;
  65.  
  66. // imports
  67.  
  68. import com.agiletunes.domain.organization.Employee;
  69. import com.agiletunes.domain.organization.OrganizationService;
  70. import com.agiletunes.security.account.Account;
  71. import com.agiletunes.security.account.AccountService;
  72. ...
  73.  
  74.  
  75. @Controller
  76. public class AuthServerCtrl implements Initializable {
  77.  
  78.  
  79. @Autowired protected AccountService accountService; // works fine
  80. @Autowired protected OrganizationService orgService; // throws Exception
  81.  
  82. ...
  83. }
Add Comment
Please, Sign In to add comment