我正在为Spring boot Rest控制器编写测试.此休止控制器将一些值写入db.
我想使用Spring为此测试提供的内存数据库.根据这个文档,我必须使用注释测试类@DataJpaTest,这会导致此错误:
java.lang.IllegalStateException: Failed to load ApplicationContext
Run Code Online (Sandbox Code Playgroud)
在错误堆栈跟踪中,我看到引发了以下异常:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to replace DataSource with an embedded database for tests. If you want an embedded database please put a supported one on the classpath or tune the replace attribute of @AutoconfigureTestDatabase. …