There are many ways to achieve asynchronous implementation:
we use the first method here
1. Add annotations.
Add the @EnableCustomConfig annotation in the springboot config to enable the asynchronous thread function
. 2. Create the asynchronous method Service and implementation class.
I am too lazy to write the interface here. I can just add it to the configuration file after testing
, otherwise it will prompt that it cannot be found. bean
3. Call the asynchronous method and check the test results.
I can just find a controller here and test it.
The result:
call the interface and postman will directly return to
the background printing at this time.
Print after 10 seconds