Created
December 15, 2015 09:43
-
-
Save relax-more/58219122f59d1d29b9cd to your computer and use it in GitHub Desktop.
@qualifier + interface and @Inject (with javax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MongoSetting{ | |
@Retention(RetentionPolicy.RUNTIME) | |
@Qualifier | |
public @interface MetaDataMongo {} | |
@Retention(RetentionPolicy.RUNTIME) | |
@Qualifier | |
public @interface UserDataMongo {} | |
@Bean | |
@MetaDataMongo | |
public MongoClient metaDataMongo() { | |
return new MongoClient(new MongoClientURI("url")); | |
} | |
@Bean | |
@ShopPurchase | |
public MongoClient shopPurchase() { | |
return new MongoClient(new MongoClientURI("url")); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MongoUser{ | |
private final MongoClient userMongo; | |
@Inject | |
public MongoUser(@UserDataMongo MongoClient userMongo){ | |
this.userMongo = userMongo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment