阿神2017-04-18 10:58:06
Autowired
修饰了该变量,Spring
容器中获取对应的Bean
is set to the value of this variable.
PHP中文网2017-04-18 10:58:06
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.
黄舟2017-04-18 10:58:06
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.
大家讲道理2017-04-18 10:58:06
This is automatically injected, ProductDaoFacade should be declared as a bean.
ps:ProductDaoFacade
这个代码写得真是太奇怪了,明明是个interface还facade(这是一个设计模式)。同时,还放了那么多常量,这是典型的constant interface
。简单来说,建议使用枚举类。如果想深入了解一下,建议参考effective java中的建议之一————接口只用于定义类型
.
天蓬老师2017-04-18 10:58:06
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