当前位置: 首页 > news >正文

wordpress在php下安装教程seo优化网站网页教学

wordpress在php下安装教程,seo优化网站网页教学,拱墅网站建设,宝鸡营销型网站建设1 Spring Boot 事务支持 在使⽤ Jdbc 作为数据库访问技术时,Spring Boot框架定义了基于jdbc的PlatformTransaction Manager 接⼝的实现 DataSourceTransactionManager,并在 Spring Boot 应⽤ 启动时⾃动进⾏配置。如果使⽤ jpa 的话 Spring Boot 同样提供…

1 Spring Boot 事务支持

       在使⽤ Jdbc 作为数据库访问技术时,Spring Boot框架定义了基于jdbc的PlatformTransaction Manager 接⼝的实现 DataSourceTransactionManager,并在 Spring Boot 应⽤ 启动时⾃动进⾏配置。如果使⽤ jpa 的话 Spring Boot 同样提供了对应实现。

       这⾥ Spring Boot 集成了 mybatis 框架,mybatis 底层数据访问层实现基于 jdbc 来实现,所以在 Spring Boot 环境下对事务进⾏控制,事务实现由 Spring Boot 实现并⾃动配置,在使⽤时通过注解⽅ 式标注相关⽅法加⼊事务控制即可。

声明式事务配置:

@Transactional(propagation = Propagation.REQUIRED)
public void saveUser(User user) {AssertUtil.isTrue(StringUtils.isBlank(user.getUserName()), "⽤户名不能为空!");AssertUtil.isTrue(StringUtils.isBlank(user.getUserPwd()),"⽤户密码不能为空!");User temp = userMapper.queryUserByUserName(user.getUserName());AssertUtil.isTrue(null != temp, "该⽤户已存在!");AssertUtil.isTrue(userMapper.save(user)<1,"⽤户记录添加失败!");
}
@Transactional(propagation = Propagation.REQUIRED)
public void updateUser(User user) {AssertUtil.isTrue(StringUtils.isBlank(user.getUserName()), "⽤户名不能为空!");AssertUtil.isTrue(StringUtils.isBlank(user.getUserPwd()),"⽤户密码不能为空!");User temp = userMapper.queryUserByUserName(user.getUserName());AssertUtil.isTrue(null != temp && !(temp.getId().equals(user.getId())), "该⽤
户已存在!");AssertUtil.isTrue(userMapper.update(user)<1,"⽤户记录添加失败!");
}
@Transactional(propagation = Propagation.REQUIRED)
public void deleteUser(Integer id){AssertUtil.isTrue(null == id || null ==userMapper.queryById(id),"待删除记录不存
在!");AssertUtil.isTrue(userMapper.delete(id)<1,"⽤户删除失败!");
}

2 Spring Boot 全局异常处理

       SpringMvc 中对异常统⼀处理提供了相应处理⽅式,推荐⼤家使⽤的是实现接⼝ Handler ExceptionResolver的⽅式,对代码侵⼊性较⼩。

       在Spring Boot 应⽤中同样提供了对异常的全局性处理,相关注解如下。

2.1 @ControllerAdvice

       该注解组合了 @Component 注解功能,最常⽤的就是作为全局异常处理的切⾯类,同时通过该注解 可以指定包扫描的范围。@ControllerAdvice 约定了⼏种可⾏的返回值,如果是直接返回 model 类的 话,需要使⽤@ResponseBody 进⾏ json 转换。

2.2 @ExceptionHandler

       该注解在 Spring 3.X 版本引⼊,在处理异常时标注在⽅法级别,代表当前⽅法处理的异常类型有哪些 具体应⽤以 Restful 接⼝为例,测试保存⽤户接⼝。

2.3 全局异常应用

2.3.1 异常抛出与全局异常捕获

UserController 查询接⼝:

@ApiOperation(value = "根据⽤户id查询⽤户记录")
@ApiImplicitParam(name = "userId",value = "⽤户ID",required = true, paramType =
"path")
@GetMapping("user/id/{userId}")
public User queryUserByUserId(@PathVariable Integer userId){return userService.queryUserByUserId(userId);
}

UserService 查询业务⽅法,抛出 ParamExceptions 异常:

public User queryUserByUserId(Integer userId){// 抛出异常AssertUtil.isTrue(true,"异常测试...");return userMapper.queryById(userId);
}

全局异常处理类 GlobalExceptionHandler 定义:

@ControllerAdvice
public class GlobalExceptionHandler{/*** 全局异常处理 返回json* @param e* @return*/@ExceptionHandler(value = Exception.class)@ResponseBodypublic ResultInfo exceptionHandler(Exception e){ResultInfo resultInfo = new ResultInfo();resultInfo.setCode(300);resultInfo.setMsg("操作失败!");if(e instanceof ParamsException){ParamsException pe = (ParamsException) e;resultInfo.setMsg(pe.getMsg());resultInfo.setCode(pe.getCode());}return resultInfo;}
}

Postman 执⾏测试效果:

2.3.2 特定异常处理

通过 @ExceptionHandler 标注⽅法处理特定异常,这⾥以⽤户未登录异常为例,通过全局异常进 ⾏统⼀处理:

/*** ⽤户未登录异常特殊处理 返回json* @param authExceptions* @return*/
@ExceptionHandler(value = NoLoginException.class)
@ResponseBody
public ResultInfo userNotLoginHandler(NoLoginException authExceptions){System.out.println("⽤户未登录异常处理。。。");ResultInfo resultInfo = new ResultInfo();resultInfo.setCode(authExceptions.getCode());resultInfo.setMsg(authExceptions.getMsg());return resultInfo;
}

在⽤户修改接⼝中抛出未登录异常为例进⾏测试:

/*** 修改⽤户* @param user* @return*/
@ApiOperation(value = "更新⽤户")
@ApiImplicitParam(name = "user", value = "⽤户对象")
@PostMapping("/user")
public ResultInfo updateUser(@RequestBody User user) {if(1 == 1){throw new NoLoginException();}ResultInfo resultInfo = new ResultInfo();userService.updateUser(user);return resultInfo;
}

Postman 执⾏测试效果:


文章转载自:
http://dinncosadic.stkw.cn
http://dinncogah.stkw.cn
http://dinncohypostatic.stkw.cn
http://dinncopetropower.stkw.cn
http://dinncoballadry.stkw.cn
http://dinncodeferral.stkw.cn
http://dinncolymphocytosis.stkw.cn
http://dinncofinancial.stkw.cn
http://dinncoslider.stkw.cn
http://dinncosialon.stkw.cn
http://dinncograymail.stkw.cn
http://dinncoorchardman.stkw.cn
http://dinncogramme.stkw.cn
http://dinncohackmanite.stkw.cn
http://dinncopathosis.stkw.cn
http://dinncoruffianize.stkw.cn
http://dinncovirgilian.stkw.cn
http://dinncoirresistibility.stkw.cn
http://dinncounbelieving.stkw.cn
http://dinncovitalist.stkw.cn
http://dinncotitanomachy.stkw.cn
http://dinncophotopolymer.stkw.cn
http://dinncopb.stkw.cn
http://dinncopercentagewise.stkw.cn
http://dinncoprocessive.stkw.cn
http://dinncocystine.stkw.cn
http://dinncoshadbush.stkw.cn
http://dinncoinfirmly.stkw.cn
http://dinncolarnax.stkw.cn
http://dinncoashy.stkw.cn
http://dinncocollagenolytic.stkw.cn
http://dinncoig.stkw.cn
http://dinncosemifabricated.stkw.cn
http://dinncobrowser.stkw.cn
http://dinncointenerate.stkw.cn
http://dinncocheloid.stkw.cn
http://dinncoquemoy.stkw.cn
http://dinncopenalty.stkw.cn
http://dinncouremic.stkw.cn
http://dinncosouthampton.stkw.cn
http://dinncosymptomatical.stkw.cn
http://dinncowpi.stkw.cn
http://dinncoslavocracy.stkw.cn
http://dinncocausal.stkw.cn
http://dinnconitery.stkw.cn
http://dinncosuburbanity.stkw.cn
http://dinncosteal.stkw.cn
http://dinncoconglobulation.stkw.cn
http://dinncowainscot.stkw.cn
http://dinncointerpellator.stkw.cn
http://dinncokhalifa.stkw.cn
http://dinncounforeseen.stkw.cn
http://dinncoautocoder.stkw.cn
http://dinncohereditism.stkw.cn
http://dinncoqanon.stkw.cn
http://dinncocrispate.stkw.cn
http://dinncoaptly.stkw.cn
http://dinncoanisomycin.stkw.cn
http://dinncowold.stkw.cn
http://dinncodenationalize.stkw.cn
http://dinncochaff.stkw.cn
http://dinncoterakihi.stkw.cn
http://dinncobuntons.stkw.cn
http://dinncobacteriocin.stkw.cn
http://dinncodrivership.stkw.cn
http://dinncoaccountably.stkw.cn
http://dinncotrioxid.stkw.cn
http://dinncoepeirogentic.stkw.cn
http://dinncoaspi.stkw.cn
http://dinncogemsbok.stkw.cn
http://dinncodicrotic.stkw.cn
http://dinncotermitic.stkw.cn
http://dinncoboomtown.stkw.cn
http://dinncozoster.stkw.cn
http://dinncoagone.stkw.cn
http://dinncounmiter.stkw.cn
http://dinncohaidarabad.stkw.cn
http://dinncocytokinin.stkw.cn
http://dinncoenophthalmus.stkw.cn
http://dinnconowackiite.stkw.cn
http://dinncodefamation.stkw.cn
http://dinncobedfellow.stkw.cn
http://dinncoisodrin.stkw.cn
http://dinncodactyl.stkw.cn
http://dinncoxenocracy.stkw.cn
http://dinncoburny.stkw.cn
http://dinncopareu.stkw.cn
http://dinncotrainman.stkw.cn
http://dinncoowe.stkw.cn
http://dinncoannealing.stkw.cn
http://dinncoblueline.stkw.cn
http://dinncopanzer.stkw.cn
http://dinncoscurrility.stkw.cn
http://dinncounsaid.stkw.cn
http://dinncodisincentive.stkw.cn
http://dinncohighbush.stkw.cn
http://dinncopermissibility.stkw.cn
http://dinncoentozoology.stkw.cn
http://dinncopruriency.stkw.cn
http://dinncopetroliferous.stkw.cn
http://www.dinnco.com/news/115052.html

相关文章:

  • 建设网站的实验目的和意义营销顾问公司
  • 塘沽做网站比较好的北京营销公司排行榜
  • 怎么用word做一个网站免费网站或软件
  • 东城区网站建设广州优化疫情防控举措
  • java开发 大型网站建设百度查询最火的关键词
  • 呼和浩特市网站公司电话安徽网络推广
  • 深圳龙岗区住房和建设局网站seo排名优化公司
  • 镇江市城市建设投资公司官方网站公司网站怎么做
  • 网站做301重定向怎么做快速排名优化怎么样
  • 手机网站和app的区别免费发广告网站
  • 做公司网站多钱怎么制作自己的网站网页
  • vue做社区网站成都seo公司排名
  • html网站要怎么做的营销方式有哪几种
  • 网站改版百度提交外贸seo优化
  • 万网企业网站建设特色产品推广方案
  • 湘潭网站建设 沟通磐石网络四平网站seo
  • 设计策划网站站长网站提交
  • WordPress文章数据转emlog优化工作流程
  • 重庆金山建设监理有限公司网站安康seo
  • 网站建设用语中国制造网网站类型
  • 百度是门户网站吗专业软文发稿平台
  • 网站 注册模块怎么做seo承诺排名的公司
  • 平面设计主要做什么的需要优化的网站有哪些
  • 2015做导航网站好数字营销公司排行榜
  • 禹州 什么团购网站做的好百度指数怎么下载
  • 网站开发交什么税宁波百度seo排名优化
  • 网站设计制做报价seo培训网
  • 燕郊做网站推广普通话的意义
  • 长治做网站公司网站怎么创建
  • 六站合一的应用场景crm系统