
spring boot
文章平均质量分 52
「已注销」
这个作者很懒,什么都没留下…
展开
-
Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazy
在学习spring boot时根据id获取一个对象时出现以下异常(返回的是json格式):{"timestamp":1500972035655,"status":500,"error":"Internal Server Error","exception":"org.springframework.http.converter.HttpMessageNotWritableException",转载 2017-07-25 16:43:30 · 3135 阅读 · 1 评论 -
spring boot中使用AOP
spring boot 中使用AOP,需要先在pom.xml中添加依赖: org.springframework.boot spring-boot-starter-aop 然后编写切面程序,例如:@Aspect@Componentpublic class HttpAspect { privat原创 2017-07-25 21:17:23 · 606 阅读 · 0 评论 -
spring 或 springboot统一异常处理
一,本文介绍spring MVC的自定义异常处理,即在Controller中抛出自定义的异常时,客户端收到更友好的JSON格式的提示。而不是常见的报错页面。二,场景描述:实现公用API,验证API key的逻辑,放在拦截器中判断(等同于在Controller中)并抛出异常,用户收到类似下图的提示:其中,Http状态Code也能自由控制。三,解决方案:1,在RateL转载 2017-07-26 15:54:06 · 5579 阅读 · 0 评论 -
spring 或springboot对controller层方法进行测试
package com.imooc.controller;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.test.autoconfigure原创 2017-07-26 16:03:05 · 7592 阅读 · 0 评论