Uploaded image for project: 'Spring Batch'
  1. Spring Batch
  2. BATCH-2161

WARN: @Bean method StepScopeConfiguration.stepScope is non-static

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.0.9, 4.0.1
    • Component/s: Core

      Description

      When using Java based configuration and the @StepScope annotation you get the following warning in the logs, when starting the application context:

      WARN ConfigurationClassEnhancer:277 - @Bean method StepScopeConfiguration.stepScope is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @Resource and @PostConstruct within the method's declaring @Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @Bean Javadoc for complete details

      A short glimpse at the StepScopeConfiguration class lets me think that the stepScope bean really can be declared static.

      See also the last chapter "BeanFactoryPostProcessor-returning @Bean methods" in the @Bean api documentation.

        Attachments

          Activity

            People

            • Assignee:
              mbenhassine Mahmoud Ben Hassine
              Reporter:
              ractive Jean-Pierre Bergamin
            • Votes:
              16 Vote for this issue
              Watchers:
              23 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: