How do I specify a BeanNamingStrategy with Spring Boot?
You can also use @ComponentScan(nameGenerator = ...)
annotation on your main Spring Boot application class:
@SpringBootApplication
@ComponentScan(nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class)
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
The SpringApplicationBuilder has a method beanNameGenerator()
that lets you pass in a custom generator.
See 22.3 Fluent builder API in the Spring Boot reference for how to work with the fluent API.
Unfortunately this doesn't help you, as this only applies to @Component
-style class annotations and not to @Bean
methods, for which the names are hard coded using this method.