Spring 使用PostgreSQL运行DataJpaTest
我用Spring Boot编写了一个jpa测试,如下所述:Spring 使用PostgreSQL运行DataJpaTest,spring,spring-boot,Spring,Spring Boot,我用Spring Boot编写了一个jpa测试,如下所述: 默认情况下,这将配置内存中的数据库。如何配置此测试,使其使用我的本地PostgreSQL db?如果要使用与常规应用程序相同的数据源,可以使用: @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(replace=Replace.NONE) @DataJpaTest包含@RunWith(SpringRunner.class) 够了。祝你好运 您是否
默认情况下,这将配置内存中的数据库。如何配置此测试,使其使用我的本地PostgreSQL db?如果要使用与常规应用程序相同的数据源,可以使用:
@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace=Replace.NONE)
@DataJpaTest
包含@RunWith(SpringRunner.class)
够了。祝你好运 您是否尝试使用application.properties定义DB?是的,我在application.properties中配置了PostgrSQL,并添加了相应的Postgres依赖项。
@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace=Replace.NONE)
@DataJpaTest
@AutoConfigureTestDatabase(replace=Replace.NONE)