I\'m a little confused as to how the inversion of control (IoC
) works in Spring
.
Say I have a service class called UserServic
You just need to annotate your service class UserServiceImpl
with annotation:
@Service("userService")
Spring container will take care of the life cycle of this class as it register as service.
Then in your controller you can auto wire (instantiate) it and use its functionality:
@Autowired
UserService userService;