0

what I know is that @Component will tell the spring that this class in instantiated by IoC container, but that does not work in case of a class that extends QuartzJobBean because this class is not initialized by spring, but with QuartzJobBean. which mean that this class is out side application context. My questions is:

  1. when to use @Component, I mean what is the properties/characteristics of a class that make spring be able to instantiate?
  2. What is the "class is out side application context" mean?
hh hh
  • 11
  • 4
  • http://stackoverflow.com/questions/6990767/inject-bean-reference-into-a-quartz-job-in-spring has already some good answers for your problem – Ralph Feb 07 '16 at 09:53
  • @Ralph, Yes, I found the solution. But I'm asking why if we add "component" to QuartzJobDean class the spring will not autowiring it. – hh hh Feb 07 '16 at 09:57
  • You already wrote that in your question, the solution for the problem is: http://stackoverflow.com/questions/6990767/inject-bean-reference-into-a-quartz-job-in-spring. But if the question was not how to solve it, but why it does not work (hard to say what the question is without any question-mark!) then the answer is: @Component (@Service, @Repository. @Component) are just annotations that tell Spring that one instance of classes should become a Spring Bean **if the class is found by component scan**, but if you (or some framework) create them by `new` Spring will do nothing with this instance – Ralph Feb 07 '16 at 10:42

0 Answers0