LazyInitializationException: could not initialize proxy - no Session

后端 未结 3 720
春和景丽
春和景丽 2020-12-09 21:04

I use spring-data-jpa with spring-boot(v2.0.0.RELEASE), I just wrote a CRUD demo on MySQL, but an exception occurs during runtime, source code as f

3条回答
  •  半阙折子戏
    2020-12-09 21:34

    Your test should be like this:

    @RunWith(SpringRunner.class)    
    
    
    @SpringBootTest
    @Transactional    
    
    public class QuestionTesting {   
    
        @Test    
        public void test() {    
    
        }    
    }    
    

提交回复
热议问题