Why is this an issue?

The Spring Framework provides several specializations of the generic @Component stereotype annotation which better express the programmer’s intent. Using them should be preferred.

Noncompliant code example

@Component // Noncompliant; class name suggests it's a @Service
public class CustomerServiceImpl {
  // ...
}

@Component // Noncompliant; class name suggests it's a @Repository
public class ProductRepository {
    // ...
}

@Component // Noncompliant; class name suggests it's a @Controller or @RestController
public class FooBarRestController {
    // ...
}

Compliant solution

@Service // Compliant
public class CustomerServiceImpl {
  // ...
}

@Repository // Compliant
public class ProductRepository {
    // ...
}

@RestController // Compliant
public class FooBarRestController {
    // ...
}

@Component // Compliant
public class SomeOtherComponent {
   // ...
}

Resources