Is there a way to turn on Spring's Async configuration from XML? All the examples I saw are using programmatic context declaration and use @EnableAsync
Is there an XML equivalent for this. In some places I saw <context:annotation-config />
being used, but this doesn't mention anything about async .
I am using Spring 4.
The @EnableAsync annotation switches on Spring's ability to run @Async methods in a background thread pool. This class also customizes the Executor by defining a new bean. Here, the method is named taskExecutor , since this is the specific method name for which Spring searches.
EnableAsync is used for configuration and enable Spring's asynchronous method execution capability, it should not be put on your Service or Component class, it should be put on your Configuration class like: @Configuration @EnableAsync public class AppConfig { }
One of the most important annotations in spring is @Configuration annotation which indicates that the class has @Bean definition methods. So Spring container can process the class and generate Spring Beans to be used in the application. This annotation is part of the spring core framework.
Did you try using this
<task:annotation-driven />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With