-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update 10-Component-Scan.md #11
base: master
Are you sure you want to change the base?
Conversation
source/10-Component-Scan.md
Outdated
- 而之前的三种 依赖注入(DI) 方式都是通过 XML 来生成 `MyServiceImpl` 的Bean对象,类运行时就是 Bean 对象 | ||
|
||
```Java | ||
Main函数中的例子(命名稍微改动,请变通): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个代码例子是从前面 IoC 那部分拿的吗?我没太懂想表达什么意思...
source/10-Component-Scan.md
Outdated
> 其实这里的 `MyPersonComponent` 和之前三个 "依赖注入(DI)" 的类是完全不一样的 | ||
> 对比一下,你会发现前三种DI都是有 sayHello()方法的,而这里的 `MyPersonComponent` 只是代替了 XML 的部分工作,本身并没有 sayHello方法。 | ||
|
||
- 这里的 `MyPersonComponent` 用处:生成`MyServiceImpl` 的Bean对象,代替了 XML 的绝大部分工作,该类本身是和`MyServiceImpl`无关的(没有继承) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段跟前面一段我大概知道你想表达是什么了,但感觉文字上可以再梳理一下,现在读起来逻辑上感觉有点乱。
前面在讲 该类本身是和
MyServiceImpl无关的(没有继承)
,后面说 而之前的三种 依赖注入(DI) 方式都是通过 XML 来生成
,这没有逻辑上的对应性。。。
source/10-Component-Scan.md
Outdated
```Java | ||
Main函数中的例子(命名稍微改动,请变通): | ||
写在Main函数里(命名稍微改动,请变通): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个例子是想表达什么东西呢,在前面有一个类似的代码
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果你把前面的类都改了名字,就能发现这段示例挺重要的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
前面是说这一节的前面吗。还是 IoC 那一节
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
指的是:前面的 DI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我没太明白这个示例是想干啥。它重要在哪儿,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段跟 https://skyline75489.github.io/Heart-First-JavaWeb/7-First-Spring-Container.html 这里的最下面那段代码,不一回事吗
source/10-Component-Scan.md
Outdated
> 对比一下,你会发现前三种DI都是有 sayHello()方法的,而这里的 `MyPersonComponent` 只是代替了 XML 的部分工作,本身并没有 sayHello方法。 | ||
|
||
- 之前的三种 依赖注入(DI) 方式的实现都是: 由 Spring 容器通过 XML 来生成 `MyServiceImpl` 类的Bean对象(类本身就是 Spring 容器操作的对象) | ||
- 而这里的 `MyPersonComponent` 类只是用来生成`MyServiceImpl` 的Bean对象,它是代替了 XML 的绝大部分工作(这个类本身和`MyServiceImpl`是没有继承关系,所以也没有 sayHello方法) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么要强调没有继承关系呢。。其实是没有任何关系啊,都不是一层层面的东西
No description provided.