Skip to content

Custom BeanNameGenerators are not considered for repository bean name generation [DATACMNS-1497] #1931

@spring-projects-issues

Description

@spring-projects-issues

slinstaedt opened DATACMNS-1497 and commented

Spring-boot allows to configure a custom BeanNameGenerator. This custom BeanNameGenerator is not picked up by spring-data, but rather the default implementation is still gonna being used. This leads to unexpected bean names at best, or subtile errors at worst, especially with spring-boot 2.0.x versions, which allow to override bean definitions by default.

I am not completely sure, if that's a bug or a feature, at least it is somehow unexpected. When I configure a custom BeanNameGenerator for spring, I would expect it to be used not only in a subset of spring-projects.

 

@SpringBootApplication public class Application { public static final AnnotationBeanNameGenerator FQCN_BEAN_NAME_GENERATOR = new AnnotationBeanNameGenerator() { @Override protected String buildDefaultBeanName(BeanDefinition definition) { String beanClassName = definition.getBeanClassName(); Assert.state(beanClassName != null, "No bean class name set"); return beanClassName; } }; public static void main(final String[] args) { SpringApplication application = new SpringApplication(Application.class); application.setBeanNameGenerator(FQCN_BEAN_NAME_GENERATOR); application.run(args); } }

Affects: 2.1.5 (Lovelace SR5)

Issue Links:

  • DATACMNS-1228 Allow custom bean name generator for repositories
    ("supersedes")
  • DATAJPA-1232 Allow custom bean name generator for repositories
    ("supersedes")

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions