Home > Back-end >  How to listen to a class variable change
How to listen to a class variable change

Time:12-24

The environment of the project: springboot
I now have a class variable, the class variables is my through a 3 seconds to perform a task to change regularly, may also be the same
If the class variables change, I need to request some API, then insert into database content

What is a good implementation way?

CodePudding user response:

This is why the need for getter/setter methods, in the setter method combined with your logic.
If you don't have permission to modify the class code, that probably can only choose the plan with bytecode enhancement to add your logic.

But no matter how, have to have a setter method, perhaps better, but I don't know.
  • Related