How to test Spring Data repositories?

前端 未结 8 1811
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 15:41

I want a repository (say, UserRepository) created with the help of Spring Data. I am new to spring-data (but not to spring) and I use this tutorial. My choice o

8条回答
  •  温柔的废话
    2020-11-29 15:48

    I solved this by using this way -

        @RunWith(SpringRunner.class)
        @EnableJpaRepositories(basePackages={"com.path.repositories"})
        @EntityScan(basePackages={"com.model"})
        @TestPropertySource("classpath:application.properties")
        @ContextConfiguration(classes = {ApiTestConfig.class,SaveActionsServiceImpl.class})
        public class SaveCriticalProcedureTest {
    
            @Autowired
            private SaveActionsService saveActionsService;
            .......
            .......
    }
    

提交回复
热议问题