Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- class PetServiceConfiguration {
- @Bean
- PetDao petDao() {
- return new PetDaoV1();
- }
- @Bean
- PetDao petDao() {
- return new PetDaoV2();
- }
- @Bean
- PetService petService(@PetDaoV1 PetDao petDaoV1, @PetDaoV2 PetDao petDaoV2) {
- if("true".equals(System.getProperty("useV1PetDao"))) {
- return new PetService(petDaoV1);
- } else {
- return new PetService(petDaoV2);
- }
- }
- }
- static class BeanIdentifiers {
- @Retention(RetentionPolicy.RUNTIME)
- @Qualifier
- public @interface PetDaoV1 {
- }
- @Retention(RetentionPolicy.RUNTIME)
- @Qualifier
- public @interface PetDaoV2 {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement