@Autowire默认模式 [英] @Autowire default mode

查看:307
本文介绍了@Autowire默认模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring @Autowire bean如何:byName或byType?如果不可能的话,是否可以使用其他模式进行第二次试用?

How does Spring @Autowire beans: byName or byType? If one is not possible, is a second trial done using another mode?

推荐答案

如果使用@Autowired进行注释,则会注入具有匹配类型的Bean(如果一个类型中有多个,则将引发异常).要指定名称,请使用@Qualifier批注.

If annotated with @Autowired it will inject the bean with the matching type (An exception will be thrown if there are more than one of a type). To specify a name use the @Qualifier annotation.

这篇关于@Autowire默认模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆