Home > Back-end >  When the conditions of use annotations in Java @ Conditional questions about Condition class executi
When the conditions of use annotations in Java @ Conditional questions about Condition class executi

Time:12-29



first defines a condition, and the condition is true by default, as shown in figure:



then @ Conditional on the Service implementation class added to the annotations, as shown in figure is the Service interface and implementation classes:





the last test class, call the implementation class insert method:



running results show that the Condition class is called the three times, this is why



could you please tell me when the three are called?

CodePudding user response:

If you can, can also provide the debugging method, now don't know how to debug, annotations should I doubt is whether conditions established (@ Conditional) up once, judge success after instantiation Impl injection in the time of the spring container (@ Service) verified once again, and then call the (@autowired) verified once again,,, knowledge guess, don't know how to verify, beg god for

CodePudding user response:

If you can, can also provide the debugging method, now don't know how to debug, annotations should I doubt is whether conditions established (@ Conditional) up once, judge success after instantiation Impl injection in the time of the spring container (@ Service) verified once again, and then call the (@autowired) verified once again,,, just wondering, don't know how to verify, beg god for

CodePudding user response:

I also encountered this problem, now know why?
  • Related