Skip to content

Instantly share code, notes, and snippets.

@ufuk
Last active December 10, 2022 21:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ufuk/16f5044f0b1a298b01a1251f0a5209cb to your computer and use it in GitHub Desktop.
Save ufuk/16f5044f0b1a298b01a1251f0a5209cb to your computer and use it in GitHub Desktop.
The easy way to disable @ Async annotation for test contexts. Same approach can be used to disable @ Scheduled annotation as well.
package ...configuration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableAsync;
@Configuration
@EnableAsync
@Profile("!test")
public class AsyncConfiguration {
}
@dharmeshjogadia
Copy link

worked, thanks

@monjasa
Copy link

monjasa commented Sep 19, 2020

thank you. eventually tests work without a pain in the neck

@aidando73
Copy link

Thanks, this was helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment