How to test Spring CrudRepository using @DataJpaTest in Spring boot 2.1.0.M4 using Junit 5

前端 未结 2 1755
天命终不由人
天命终不由人 2021-01-27 02:49

I cannot test my spring crud repository using spring boot 2.1.0.M4 with Junit5 and @DataJpaTest. I am using the following spring crud repository interface.

相关标签:
2条回答
  • 2021-01-27 02:58

    Do not mix @SpringBootTest with @DataJpaTest

    From JavaDoc's one can read:

    Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)} for a typical JPA test. Can be used when a test focuses only on JPA components.

    For full integration tests you should instead use @SpringBootTest

    If you are looking to load your full application configuration, but use an embedded database, you should consider {@link SpringBootTest @SpringBootTest} combined with {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this annotation.

    0 讨论(0)
  • 2021-01-27 03:02

    I think your problem is cause by changed naming strategy. Try to check this issue

    0 讨论(0)
提交回复
热议问题