springMVC+mybatis实现批量插入遇到异常回滚

在spring-mvc配置文件中加如下配置:



    



然后在对应的service类下加如下注解:

@Transactional(rollbackFor = Exception.class)

示例代码:

@Service
public class MapServiceImpl implements MapService {
    @Autowired
    private MapDao dao;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void insertMapPoint(List mapPointList) {
        for(int i=0;i 
  

 

你可能感兴趣的:(java)