SpringBoot测试JPA存储库错误

时间:2017-08-24 05:35:29

标签: spring-boot spring-data-jpa spring-boot-test

我有一个springboot应用程序和一个JPARepository接口定义。

我有一个BeansConfigTest配置类,我正在自动装配JPARepository并且有一个测试类。

在运行测试用例时,我遇到异常:

Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.MyMetaInfoRepository]: Specified class is an interface
    10:59:08,770  INFO main LocalContainerEntityManagerFactoryBean:destroy:548 - Closing JPA EntityManagerFactory for persistence unit 'default'
    10:59:08,791  INFO main AutoConfigurationReportLoggingInitializer:logAutoConfigurationReport:

我的应用程序属性类是:

spring.datasource.url=jdbc:h2:mem:UserAttributeConfig;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.platform=h2
spring.datasource.username = sa
spring.datasource.password =
spring.datasource.driverClassName = org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

和BeanConfifTest类有注释

@SpringBootConfiguration
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2)
@ComponentScan(basePackages = {"com.example.configtest","com.example.db.repository"},
       excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,
              value = CommandLineRunner.class))
@EnableAutoConfiguration
public class BeansConfigTest {
..}

这个错误可能是什么问题?

0 个答案:

没有答案