Skip to content

Instantly share code, notes, and snippets.

@relax-more
Created December 15, 2015 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save relax-more/58219122f59d1d29b9cd to your computer and use it in GitHub Desktop.
Save relax-more/58219122f59d1d29b9cd to your computer and use it in GitHub Desktop.
@qualifier + interface and @Inject (with javax
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"));
}
}
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