判断是否是唯一索引异常

if(e instanceof SQLIntegrityConstraintViolationException) {
                //RunTimeException异常抛出了事务会回滚
                throw new BaseRuntimeException("用户不能多重角色,如果需要请联系管理员!");
            }  else {
                throw new BaseRuntimeException("服务器异常,请联系管理员");
            }
原文地址:https://www.cnblogs.com/huqi96/p/14150867.html