테스트 중에 데이터베이스를 만들고로드하기 위해 스크립트 구성과 함께 H2 내장 데이터베이스를 사용하려고합니다.스프링 및 jdbc DataSourceTransactionManager를 사용하여 H2 데이터베이스 채우기
잘 작동하지만 데이터베이스 상호 작용을위한 트랜잭션 지원을 추가하려고 할 때 컨텍스트 초기화 중에 오류가 발생합니다. 여기
내 스프링 설정입니다 : 여기<bean id="dbcpDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.h2.Driver" />
<property name="url" value="jdbc:h2:mem:embeddedH2Database;MODE=Oracle;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
<jdbc:embedded-database id="embeddedH2Database" type="H2">
<jdbc:script location="classpath:db/sql/c`enter code here`reate-db.sql" />
<jdbc:script location="classpath:db/sql/insert-data.sql" />
</jdbc:embedded-database>
<tx:advice id="txAdvice" transaction-manager="txManager">
<!-- the transactional semantics... -->
<tx:attributes>
<tx:method name="*" timeout="60" />
</tx:attributes>
</tx:advice>
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dbcpDataSource"/>
</bean>
<aop:config>
<aop:pointcut id="serviceOperation" expression="execution(* x.y.service.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation"/>
</aop:config>
는 콩 생성 오류입니다 :
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedH2Database': Cannot create inner bean '(inner bean)#23bff419' of type [org.springframework.jdbc.datasource.init.CompositeDatabasePopulator] while setting bean property 'databasePopulator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#23bff419': Cannot create inner bean '(inner bean)#1d2bd371' of type [org.springframework.jdbc.datasource.init.ResourceDatabasePopulator] while setting bean property 'populators' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1d2bd371': Cannot create inner bean '(inner bean)#65fe9e33' of type [org.springframework.jdbc.config.SortedResourcesFactoryBean] while setting bean property 'scripts'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#65fe9e33': Post-processing of FactoryBean's object failed; nested exception is java.lang.AssertionError