我用@DataJpaTest注解创建了一个测试。hsqldb已配置,但我收到错误:
No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate]
在这个项目中,我使用了JPA存储库和JdbcTemplates。当我使用实际的Oracle DB配置时,它工作得很好。为什么不自动配置JdbcTemplate?我应该怎么做才能解决这个问题?
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {MyApplication.class})
@DataJpaTest
我在mySQL上运行了一个小型数据库应用程序。
我想使用H2进行测试。
我向build.gradle添加了必要的依赖项:
runtimeOnly 'com.h2database: h2‘
plugins {
id 'org.springframework.boot' version '2.7.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'idea