SPRINGMVC & Spring Ioc+bean
Spring's IOC container contains the SPRINGMVC IOC, that is, the SPRINGMVC-configured bean can invoke spring-configured beans, not vice versa.
1.1 explains why the bean is not injected automatically in the Application.xml file, but is automatically injected into the Spring-servlet.xml file
Use annotations to automatically put beans into the IOC container
2.1 @Controller (control layer); @Service (service layer); @Repository (persistent layer dao); @Component (generic component)
2.2 After using annotations, you must scan the packages in Applicationcontext.xml or spring-servlet.xml files <context:component-scan base-package= " You need to scan the package "></context:component-scan>
Get the bean from the IOC container and inject it
3.1 Manually configuring the bean, pay attention to which IOC container your configured bean is in (SPRING&SPRINGMVC)
3.2 Automatic injection, using the annotation @autowired (which can be combined with @qualifier ("Bean's name"), can also be used to @resources from the dynamic injection. The former match according to the type, and the latter according to the name.
3.3 Injected when there is one to note: Do not create a new instance, or you can not inject success, is generally null pointer exception. Injection can also be understood as an instance of new (singleton mode), so you new one, it is equivalent to take someone else's way, others have no way to go.