## Why is this an issue?

Naming conventions play a crucial role in maintaining code clarity and readability. The uniqueness of bean names in Spring configurations is vital to the clarity and readability of the code. When two beans share the same name within a configuration, it is not obvious to the reader which bean is being referred to. This leads to potential misunderstandings and errors.

## How to fix it

To address this issue, ensure each bean within a configuration has a distinct and meaningful name. Choose names that accurately represent the purpose or functionality of the bean.

### Code examples

#### Noncompliant code example

    @Configuration
    class Config {
      @Bean
      public User user() {
        return currentUser();
      }
      @Bean
      public User user(AuthService auth) { // Noncompliant
        return auth.user();
      }
    }

#### Compliant solution

    @Configuration
    class Config {
      @Bean
      public User user() {
        return currentUser();
      }
      @Bean
      public User userFromAuth(AuthService auth) {
        return auth.user();
      }
    }

## Resources

### Documentation

- Spring IO - Basic concepts: @Bean and @Configuration
- Spring IO - Using the @Configuration annotation
- Spring IO - Using the @Bean annotation