亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java中成員變量productDao并沒有初始化,為什么可以調(diào)用方法?
伊謝爾倫
伊謝爾倫 2017-04-18 10:56:06
0
6
734

伊謝爾倫
伊謝爾倫

小伙看你根骨奇佳,潛力無限,來學(xué)PHP伐。

reply all(6)
阿神

Autowired修飾了該變量,Spring容器中獲取對應(yīng)的Bean is set to the value of this variable.

洪濤

You use the Spring framework and annotate the ProductController with @Controller to be managed by Spring. When ProductController is instantiated, it will search for @Autowired and inject other instances managed by Spring.

黃舟

productDao uses the @Autowired annotation, which means that instances are automatically injected from the Spring context.

Classes in the Spring context are all singletons. After startup, these classes will be initialized in the context, so you can call them directly in ProductController.

大家講道理

This is automatically injected, ProductDaoFacade should be declared as a bean.

ps:ProductDaoFacade這個代碼寫得真是太奇怪了,明明是個interface還facade(這是一個設(shè)計模式)。同時,還放了那么多常量,這是典型的constant interface。簡單來說,建議使用枚舉類。如果想深入了解一下,建議參考effective java中的建議之一————接口只用于定義類型.

Peter_Zhu

spring found the @Controller annotation during package scanning and managed and maintained the controller class. After discovering @Autowired, it started the assembly mechanism and searched in the context of the beans managed by Spring according to the changed attribute type and injected it. The professional term is called IOC

伊謝爾倫

This framework called Chun has done it for you<_<

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template