I\'m a little confused as to how the inversion of control (IoC
) works in Spring
.
Say I have a service class called UserServic
Keep in mind that you must enable the @Autowired
annotation by adding element
into the spring configuration file. This will register the AutowiredAnnotationBeanPostProcessor
which takes care the processing of annotation.
And then you can autowire your service by using the field injection method.
public class YourController{
@Autowired
private UserService userService;
}
I found this from the post Spring @autowired annotation