SpringBoot事务处理

 Service层
   @Service
   public class GirlService{
       @Autowired
       private GirlRepository girlRepository;
       @Transactional
       public void insertTwo(){
           Girl girlA=new Gril();
            girlA.setCupSize("A");
            girlA.setAge(18);
            return  girlRepository.save(girlA);

            Girl girlB=new Gril();
            girlA.setCupSize("B");
            girlA.setAge(19);
            return  girlRepository.save(girlB);
       }
   }      





   GirlController中添加
   @Autowired
   private GrilService grilService

你可能感兴趣的:(springboot)