是否可以在春季使用自定义qualifier
并返回Map<MyEnum, Bean>
?
示例代码:
enum class MyEnum {
TYPE1,
TYPE2
}
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@Qualifier
annotation class MyQualifier(val value: MyEnum)
interface BaseBean
@Service
@MyQualifier(MyEnum.TYPE1)
class Bean1: BaseBean
@Service
@MyQualifier(MyEnum.TYPE2)
class Bean2: BaseBean
@Service
class MyService @Autowired constructor(private val types: Map< MyEnum, BaseBean>)
那么如何将所有带有自定义限定符的bean注入此Map
中?在service
中?有办法吗?