File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -30,11 +30,11 @@ public class MyPersonComponent {
30
30
}
31
31
```
32
32
33
- 这时候运行程序,会导致异常,Srping 提示的信息是:
33
+ 这时候运行程序,会导致异常,Spring 提示的信息是:
34
34
35
35
> No qualifying bean of type 'com.skyline.model.Person' available: expected single matching bean but found 2: aPerson,bPerson
36
36
37
- 这个错误已经把问题说明的很清楚了,Spring 并不知道我们想使用哪个 Person,因此抛出了异常。
37
+ 这个错误已经把问题说明的很清楚了,同时有两个 Person 存在, Spring 并不知道我们想使用哪个 Person,因此抛出了异常。
38
38
39
39
为了解决这个问题,Spring 提供了另外的机制,允许我们将额外的信息提供给 Spring,好让它可以正确地找到对应的 Bean。
40
40
@@ -95,4 +95,4 @@ public void IWantMike(@Qualifier("Mike") Person person) {
95
95
}
96
96
```
97
97
98
- > 细心的同学可能观察到了,` @Autowired ` 和在 XML 里进行 Bean 的 ref 还是有一些差别。在 XML 中我们是基于 id/name 去引用依赖的,而 ` @Autowired ` 从本质上就是一种基于类型的依赖机制,` Qualifier ` 是一种额外的特殊情况。
98
+ > 细心的同学可能观察到了,` @Autowired ` 和在 XML 里进行 Bean 的 ref 还是有一些差别。在 XML 中我们是基于 id/name 去引用依赖的,而 ` @Autowired ` 从本质上就是一种基于类型的依赖机制,` @ Qualifier` 是一种额外的特殊情况。
You can’t perform that action at this time.
0 commit comments