[英]How to inject an interface that inherits from another interface that has an implementation in Spring
我在我的應用程序的基礎設施 package 中有一個接口和實現。 在領域層,我想用另一個繼承自基礎設施接口的接口來訪問這個接口。 但是Spring無法識別這個接口對應的bean
基礎設施 package
interface PushNotificationService {
fun push(): Mono<Void>
}
@Service
class PushNotificationServiceImpl() : PushNotificationService {
override fun send(): Mono<Void> {
//Call grpc to push notification
}
}
域 package
//import PushNotificationService from the infrastructure package
interface PushNotificationService: PushNotificationService
@Service
class MessengerServiceImpl(
@Autowired val pushNotificationService: PushNotificationService //I want to use the interface defined in my domain layer
)
有沒有辦法做這樣的事情?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.