내 applicationContext 초기화가 Spring 3.2.1에서 잘 작동했습니다.Spring 4.0.9 applicationContext 초기화가 멈추지 만 3.2.1이 아닌 이유는 무엇입니까?
그러나 코드 나 bean 정의를 변경하지 않고 4.0.9로 업그레이드했을 때 초기화가 중단되었습니다. 다음 진술은 계속 발생했습니다. 그래도 명확한 순환 참조가 없습니다.
Requested bean is currently in creation: Is there an unresolvable circular reference?
나는 계속 조사했다. 나는 의도적으로 빈 정의를 제거했다.
- 봄 3.2.1 예상 결과가 있습니다. 치명적인 오류가 거의 즉시 발생했습니다.
- 스프링 4.0.9는 여전히이 무한 루프에 들어가서, 다른 씨드 빈 정의를 찾아 내서 작동하도록했습니다.
다음은 계속 발생하는 로그 문입니다.
[factory.support.DefaultListableBeanFactory.getTypeForFactoryBean()] - Ignoring bean creation exception on FactoryBean type check:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'someSeedBean-which-is-different-in-every-instance-of-this-log' defined in the class path resource ........ ;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'someDataSource' is defined
변경된 기능은 무엇입니까? 어떤 아이디어라도 도움이 될 것입니다. 봄 3.X에 있지만 4.0.9에서 작동 모두 봄 3.x 및 4.x의
<bean id="abstractDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close" abstract="true" scope="singleton">
<property ....>
</bean>
<bean id="someDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close" scope="singleton" parent="abstractDataSource">
<property name="driverClass" .... />
</bean>
<bean id="someSessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource"> <ref bean="someDataSource" /> </property>
<property name="packagesToScan"> <list>......</list> </property>
....
콩 정의에서 작업
콩 정의. 나는 봄 4.0.9로 얻을
@Configuration
public class SomeSpringConfiguration{
// Moving this beanDef to Java for features not available in XML
@Bean(destroyMethod = "close")
public DataSource someDataSource() { // also tried setting this to ComboPooledDataSource
// verified that this beanDefinition is recognized by Spring
// but this bean is never created/this method is never executed
...
return datasource;
}
}
<bean class="SomeSpringConfiguration" />
<bean id="someSessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource"> <ref bean="someDataSource" /> </property>
<property name="packagesToScan"> <list>......</list> </property>
....
</bean>
오류가
Cannot resolve reference to bean 'someSessionFactory' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException:
Error creating bean with name 'someSessionFactory':
Requested bean is currently in creation: Is there an unresolvable circular reference?
응용 프로그램이 XML, @Component 및 @Configuration를 통해 /에 정의 된 콩의 수천을 가지고 있습니다입니다. 복잡한 Bean 빌드 프로 시저를 실행하기 위해 xml에서 @Configuration 클래스로 Bean 위를 이동해야했습니다.
----------------------- UPDATE 나는이 문제를 발견 : 'MethodInvokingFactoryBeans와의 t [MIB] 용도'. 몇 가지 이유 때문에, Spring 4는 많은 수의 MIB가있는 상황에서 혼란스러워졌습니다. 정확히 같은 코드 기반은 Spring 3과 함께 잘 작동했습니다. 다양한 MIB에 의해 수행 된 모든 로직을 ApplicationListener로 마이그레이션했습니다. ApplicationListener는 MIB에 대한 의도 된 대체품이 아니지만 제 경우에는 MIB가 Spring에서 관리하지 않는 클래스에 Spring Bean의 정적 삽입을 수행하기 때문에 리스너에서 논리를 재현 할 수 있습니다. 이 문제를 해결할뿐만 아니라 Spring 시작 시간을 300 초에서 ~ 200 초로 줄였습니다.
불행히도 스프링의 근본 원인을 파악하거나 작은 코드베이스 (여기에 공유)에서 문제를 재현 할 수 없었습니다.
someDataSource라는 bean이 있습니까, 정의가 표시 될 수 있습니까? 종속성이 있습니까?이를 볼 수 있습니까? –
@RC 게시 된 bean 정의. 이것을 봐주세요. – phani