0

I have a Spring web app I am configuring programatically. I am trying out Apache Shiro as my authentication framework and I have run into issues integrationg Shiro with Spring, specifically using programmatic configuration (as I decided I did not want to write lots of XML). This is the relevant code snippet:

@Configuration //Replaces Spring XML configuration
@EnableTransactionManagement //Enables declarative Transaction annotations
public class SpringAppConfig {
    @Bean
    public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
        return new LifecycleBeanPostProcessor();
    }
}

When I start my web app, I get errors where Spring is unable to process any of my beans using annotations.

Jensen Ching
  • 3,144
  • 4
  • 26
  • 42

1 Answers1

0

Based on the comments in this issue: https://issues.apache.org/jira/browse/SHIRO-222

I should declare the method as static in order to avoid early Configuration bean creation (I'm actually not too sure yet how Spring configuration mechanisms work which is probably why I ran into this error).

@Bean
public static LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
    return new LifecycleBeanPostProcessor();
}

This prevents all the errors from happening.

Jensen Ching
  • 3,144
  • 4
  • 26
  • 42