Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. @Configuration
  2. class PetServiceConfiguration {
  3. @Bean
  4. PetDao petDao() {
  5. return new PetDaoV1();
  6. }
  7.  
  8. @Bean
  9. PetDao petDao() {
  10. return new PetDaoV2();
  11. }
  12.  
  13. @Bean
  14. PetService petService(@PetDaoV1 PetDao petDaoV1, @PetDaoV2 PetDao petDaoV2) {
  15. if("true".equals(System.getProperty("useV1PetDao"))) {
  16. return new PetService(petDaoV1);
  17. } else {
  18. return new PetService(petDaoV2);
  19. }
  20. }
  21. }
  22.  
  23. static class BeanIdentifiers {
  24.  
  25. @Retention(RetentionPolicy.RUNTIME)
  26. @Qualifier
  27. public @interface PetDaoV1 {
  28.  
  29. }
  30.  
  31. @Retention(RetentionPolicy.RUNTIME)
  32. @Qualifier
  33. public @interface PetDaoV2 {
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement