Spring 弹簧测试装置可以';无法找到@Test注释
我已经设置了spring test dbunit,但出现以下异常:Spring 弹簧测试装置可以';无法找到@Test注释,spring,dbunit,spring-test-dbunit,Spring,Dbunit,Spring Test Dbunit,我已经设置了spring test dbunit,但出现以下异常: testSometing(com.my.package.dbunit.dbunit)运行时间:13.013秒您的spring测试dbunit版本很可能与您的spring版本不兼容spring测试数据库单元在1.3.0版(似乎是最新版本)中依赖于spring 4.2.5。您可能正在项目中使用较新的Spring版本,该版本在AnnotationUtils中不再具有findAnnotation方法 你现在基本上可以做两件事: 使用Sp
testSometing(com.my.package.dbunit.dbunit)运行时间:13.013秒您的
spring测试dbunit
版本很可能与您的spring版本不兼容<代码>spring测试数据库单元在1.3.0版(似乎是最新版本)中依赖于spring 4.2.5。您可能正在项目中使用较新的Spring版本,该版本在AnnotationUtils
中不再具有findAnnotation
方法
你现在基本上可以做两件事:
您的
spring-test-dbunit
版本很可能与您的spring版本不兼容<代码>spring测试数据库单元在1.3.0版(似乎是最新版本)中依赖于spring 4.2.5。您可能正在项目中使用较新的Spring版本,该版本在AnnotationUtils
中不再具有findAnnotation
方法
你现在基本上可以做两件事:
package com.my.package.dbunit;
import com.github.springtestdbunit.DbUnitTestExecutionListener;
import com.github.springtestdbunit.annotation.DatabaseSetup;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/test-application.xml")
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class, DbUnitTestExecutionListener.class})
public class DbUnit {
@Autowired
public MyDAO myDAO;
@Test
@DatabaseSetup("target/partial.xml")
public void testSometing() throws Exception {
int rootId = 123;
MyClass root = myDAO.getById(rootId);
}
}
...
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
...
...
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.springtestdbunit</groupId>
<artifactId>spring-test-dbunit</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
...