Why does Autowiring not function in a thread?

前端 未结 5 433
别那么骄傲
别那么骄傲 2021-02-06 07:13

I\'ve made a maven project in Spring 3.0, I\'ve made some DAO, services and controllers, in one of mine controller I call a service in which I start a thread, the problem is tha

5条回答
  •  情书的邮戳
    2021-02-06 07:43

    If you need to autowire a newly created instance (without container support) invoke

    ctx.getAutowireCapableBeanFactory().autowireBean(instance)

    where ctx is your ApplicationContext and instance the newly created instance.

    I asked a similar question here

提交回复
热议问题