Detailed explanation of bean injection under spring multithreading
•
Java
This paper introduces the detailed explanation of bean injection under spring multithreading and shares it with you as follows:
problem
The multithreaded injection of userthreadservice in spring is not included, and the userthreadservice is null exception is displayed
The code is as follows:
Solution I
Pass the service to be injected through the structure. The code is as follows:
Solution II
Get the required service from ApplicationContext
Spring loads its own defined applicationcontextholder class
Get the instance according to the name of the bean
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码