Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1497

Custom BeanNameGenerators are not considered for repository bean name generation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.5 (Lovelace SR5)
    • Fix Version/s: 2.2 M3 (Moore)
    • Component/s: Repositories
    • Labels:
      None

      Description

      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);
          }
      }
      
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              slinstaedt slinstaedt
              Last updater:
              Spring Issues Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: