Skip to content

Instantly share code, notes, and snippets.

@FrancescoJo
Last active March 31, 2023 08:54
Show Gist options
  • Save FrancescoJo/f1ed9534c7738e72c23cfbf4fc850575 to your computer and use it in GitHub Desktop.
Save FrancescoJo/f1ed9534c7738e72c23cfbf4fc850575 to your computer and use it in GitHub Desktop.
How can we avoid DI error in this scenario without any annotations such as @primary, @qualifier, @resource?
@Repository(UserReadonlyRepository.NAME)
interface UserReadonlyRepository {
suspend fun findById(userId: UUID): User?
companion object {
const val NAME = "a.b.c.UserReadonlyRepository"
}
}
@Repository(UserRepository.NAME)
interface UserRepository : UserReadonlyRepository {
suspend fun save(user: User): User
companion object {
const val NAME = "a.b.c.UserRepository"
}
}
@Bean
fun refundMyPurchaseHistoryUsecase(
@Qualifier(UserRepository.NAME)
users: UserRepository,
products: ProductRepository,
receipts: PurchaseReceiptRepository
) : ListMyPurchaseHistoryUsecase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment