Issue
I wrote a jpa test with Spring Boot as explained here: rel="noreferrer">https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4
@RunWith(SpringRunner.class)
@DataJpaTest
public class UserRepositoryTests {
@Autowired
private TestEntityManager entityManager;
...
}
This configures a in-memory db by default. How can I configure this test, that it uses my local PostgreSQL db?
Solution
If you want to use the same datasource as your regular application you can use:
@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace=Replace.NONE)
Answered By - Phil Webb
Answer Checked By - Robin (JavaFixing Admin)