Java – how do you ensure that spring @ EventListener is called first?
•
Java
When implementing the applicationlister interface, there is an option to implement ordered to specify the call order
Solution
Use the @ order annotation on the @ EventListener method:
@EventListener(MyEvent.class) @Order(10) public void myListener() { /* ... */ }
As with the ordered interface, lower values have higher priority
Start with @ EventListener Javadoc:
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
二维码