Consistent naming of beans is important for the readability and maintainability of the code. More precisely, according to the Spring
documentation:
Naming beans consistently makes your configuration easier to read and understand. Also, if you use Spring AOP, it helps a lot when applying advice to a set of beans related by name.
Not following accepted conventions can introduce inconsistent naming, especially when multiple developers work on the same project, leading to
technical debt.
The spring documentation establishes a naming convention that consists of camel-cased names with a leading lowercase letter.
This rule raises an issue when a bean name defined in one of the following annotations does not adhere to the naming convention:
-
@Bean
-
@Configuration
-
@Controller
-
@Component
-
@Qualifier
-
@Repository
-
@Service