hibernate拦截器循环依赖的Spring配置
我正试图在基于spring的项目中实现hibernate截取以创建日志表,但我在配置文件上遇到了困难。hibernate拦截器循环依赖的Spring配置,spring,hibernate,Spring,Hibernate,我正试图在基于spring的项目中实现hibernate截取以创建日志表,但我在配置文件上遇到了困难。 一切正常,但拦截器从不触发 Im我的拦截器我有@Autowired我的Dao,因为我需要访问它以在日志表中保存新的输入。所有DAO在参数中都有会话工厂,因此当我尝试添加 <property name="entityInterceptor"> <bean class="com.mypackage.MyLoggingInterceptor"></bean>
一切正常,但拦截器从不触发 Im我的拦截器我有
@Autowired
我的Dao,因为我需要访问它以在日志表中保存新的输入。所有DAO在参数中都有会话工厂,因此当我尝试添加
<property name="entityInterceptor">
<bean class="com.mypackage.MyLoggingInterceptor"></bean>
</property>
如果我不添加entityInterceptor
属性,我的程序工作正常,但从未调用过interceptor。我应该如何解决这种循环依赖性
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [URL]: Cannot resolve reference to bean 'MyLoggingInterceptor' while setting bean property 'entityInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyLoggingInterceptor': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.mypackage.UserLogDao com.mypackage.MyLoggingInterceptor.userLogDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserLogDao' defined in URL [URL]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject