Let's start with the words. In the service layer package, there is an implementation class userweixinserviceimpl, which is implemented in the controller userweixincontroller @ Autowired automatic assembly, testing the easy-to-use, but also in the toolkit (and the controller package is the same level) in a class @ Autowired automatically assembles the implementation class. When it is called, the information printed to the console shows that it is null. Annotation is used on the tool class header @ Component, which is explained in combination with the picture.
Look at the figure below, in the controller package com.xdf.wxpad Userweixinserviceimpl is automatically assembled in the userweixincontroller in. Controller through @ Autowired, which is easy to use in browser test.
Take a look at the picture below . xdf . wxpad . The class in wxutil is also used in wxutil @ Autowired assembles the same class, and the tool class header uses annotations @ Component。 When a service of type userweixinserviceimpl is used in a method in the tool class, the print is null in the console.
Can't you assemble classes of the same type in multiple places like this? Or is my usage wrong? QQ = 409223171