## Why is this an issue?

`@Configuration` is a class-level annotation indicating that an object is a source of bean definitions. `@Configuration` classes declare beans through `@Bean`-annotated methods. Calls to `@Bean` methods on `@Configuration` classes can also be used to define inter-bean dependencies. The `@Bean` annotation indicates that a method instantiates, configures, and initializes a new object to be managed by the Spring IoC container.

Annotating a method of a bean with `@Async` will make it execute in a separate thread. In other words, the caller will not wait for the completion of the called method.

The `@Async` annotation is not supported on methods declared within a `@Configuration` class. This is because `@Async` methods are typically used for asynchronous processing, and they require certain infrastructure to be set up, which may not be available or appropriate in a `@Configuration` class.

## How to fix it

Don’t use `@Async` annotations on methods of `@Configuration` classes.

### Code examples

#### Noncompliant code example

    @EnableAsync
    @Configuration
    public class MyConfiguration {

      @Async // Noncompliant - This is not allowed
      public void asyncMethod() {
        // ...
      }
    }

#### Compliant solution

    @EnableAsync
    @Configuration
    public class MyConfiguration {

      public void method() {
        // ...
      }
    }

## Resources

### Documentation

- Spring Framework - @Async
- Spring Framework - Using the @Configuration annotation
- Spring Framework - Basic Concepts: @Bean and @Configuration

### Articles & blog posts

- Baeldung - How To Do @Async in Spring