The Spring Framework provides several specializations of the generic @Component stereotype annotation which better express the
programmer’s intent. Using them should be preferred.
@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 {
// ...
}
@Service // Compliant
public class CustomerServiceImpl {
// ...
}
@Repository // Compliant
public class ProductRepository {
// ...
}
@RestController // Compliant
public class FooBarRestController {
// ...
}
@Component // Compliant
public class SomeOtherComponent {
// ...
}