How to use @Autowired in a Quartz Job?

前端 未结 5 2033
余生分开走
余生分开走 2020-12-25 11:52

i am using quartz with spring and i want to inject/use another class in the job class and i don\'t know how to do it correctly

the xml:



        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-25 12:46

    ApplicationContext springContext = 
        WebApplicationContextUtils.getWebApplicationContext(
            ContextLoaderListener.getCurrentWebApplicationContext().getServletContext()
        );
    Bean bean = (Bean) springContext.getBean("beanName");
    bean.method();
    

提交回复
热议问题