Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-8269

BeanFactoryPostProcessor breaks default post-processing of @Configuration classes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 3.1 M1
    • Fix Version/s: 3.1 M2
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      When using AnnotationConfigApplicationContext, if I declare at least one @Bean of type BeanFactoryPostProcessor (even if it's a stub that doesn't do anything), this breaks default post-processing of the @Configuration bean, meaning that @Autowired fields are no longer injected, @PostConstruct methods are not called, etc.

      I'm attaching a test case to prove my point.

      A workaround is to manually add the relevant BeanPostProcessors (like AutowiredAnnotationBeanPostProcessor and CommonAnnotationBeanPostProcessor) to BeanFactory.

      Same thing happens in web app when I use ContextLoaderInitializer to load @Configuration classes or define them through XML config. My particular case is that I use MyBatis-Spring integration and I cannot declare a @Bean of type org.mybatis.spring.mapper.MapperScannerConfigurer using annotation config, because this bean is a BeanFactoryPostProcessor and thus breaks autowiring of @Configuration class.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cbeams Chris Beams
                Reporter:
                prickus Osvaldas Grigas
                Last updater:
                Juergen Hoeller
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 34 weeks, 4 days ago