我正在使用spring boot 2,我试图通过创建带注释的测试来对存储库执行集成测试:
@RunWith(SpringRunner.class)
@DataJpaTest
public class SomeTest {
@Autowired
private TestEntityManager entityManager;
@Autowired
private SomeRepository repository;
// CONTENT
}
我有liquibase迁移,我希望这些测试在特殊的mysql数据库上运行。但是,弹出启动默认情况下是尝试配置嵌入式h2数据库。从POM文件中删除h2依赖项后,我得到了:
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
当我运行我的应用程序时,它运行得很好,因为我已经用application.yml
填充了正确的数据库连接。但是当我将application.yml添加到测试资源时没有任何反应。
有人能告诉我如何正确配置这些测试以使用mysql数据库吗?