No transactional EntityManager available

前端 未结 3 1903
轮回少年
轮回少年 2021-01-13 06:52

I am new to the jpa and spring world and I am currently doing some unit test on a simple method but keep getting this error message only when I run my test class in unit tes

3条回答
  •  渐次进展
    2021-01-13 07:49

    I think EntityManager is null.Try Like this,may be it work

    private EntityManager entityManager = null;
    
    @PersistenceContext
    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }
    

提交回复
热议问题