background:
When calling Alibaba Cloud Privacy Protection, the receipt message of a call record is a consumer thread queue. Others told me this, because I didn't see where the thread was at all, so I treated it as an ordinary code and got the return value. Then insert into the database later
But I added everything that should be added here. The imported service kept reporting a null pointer. I was so angry that I
couldn't solve it so I went to the supervisor. The supervisor told me that this was a thread, and your injection would definitely not work. of. Then it disappeared. I was very happy. At least I had an idea and knew how to find a solution. However, after various Baidu and various attempts, it still didn’t work. Later, I went to find a colleague who had done multi-threading, and then the colleague gave me a tool to change the things that needed to be injected into my own.
@Service
public class MapperUtil {
@Autowired
public MoveCarService moveCarService;//改成自己的
private static SimpleDateFormat df =
new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
private int dueTime = 86400000;
public static MapperUtil mapperUtil; // 关键2
public MapperUtil() {
}
// 关键3
@PostConstruct
public void init() {
mapperUtil = this;
mapperUtil.moveCarService = this.moveCarService;//改成上面对应的
}
}
Then just call