更新时间:2021-11-02 02:59:24
广告。 1:你可以使用 @Qualifier
注释或使用 @Resource
进行自动装配,而不是 @自动装配
,默认为字段名称而不是类型。
Ad. 1: you can use @Qualifier
annotation or autowire using @Resource
as opposed to @Autowired
which defaults to field name rather than type.
广告。 2:它将在运行时失败,说两个bean正在实现此接口。如果您的其中一个bean另外使用 @Primary
进行注释,在按类型自动装配时将首选。
Ad. 2: It will fail at runtime saying that two beans are implementing this interface. If one of your beans is additionally annotated with @Primary
, it will be preferred when autowiring by type.