指定Shiro';编程Spring@配置中的s LifecycleBeanPostProcessor导致错误
我有一个SpringWeb应用程序,我正在进行编程配置。我正在尝试使用ApacheShiro作为我的身份验证框架,并且在将Shiro与Spring集成时遇到了一些问题,特别是在使用编程配置时(因为我决定不想编写大量XML)。这是相关的代码片段:指定Shiro';编程Spring@配置中的s LifecycleBeanPostProcessor导致错误,spring,shiro,Spring,Shiro,我有一个SpringWeb应用程序,我正在进行编程配置。我正在尝试使用ApacheShiro作为我的身份验证框架,并且在将Shiro与Spring集成时遇到了一些问题,特别是在使用编程配置时(因为我决定不想编写大量XML)。这是相关的代码片段: @Configuration //Replaces Spring XML configuration @EnableTransactionManagement //Enables declarative Transaction annotations p
@Configuration //Replaces Spring XML configuration
@EnableTransactionManagement //Enables declarative Transaction annotations
public class SpringAppConfig {
@Bean
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
return new LifecycleBeanPostProcessor();
}
}
当我启动我的web应用程序时,我会遇到一些错误,Spring无法使用注释处理我的任何bean。根据本期中的评论: 我应该将该方法声明为
static
,以避免早期创建配置bean(实际上我还不太确定Spring配置机制是如何工作的,这可能就是我遇到此错误的原因)
这可以防止所有错误的发生
@Bean
public static LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
return new LifecycleBeanPostProcessor();
}