两个异常处理的接口 AuthenticationEntryPoint:用来解决匿名用户访问无权限资源时的异常,也就是跟token相关的资源异常 AccessDeniedHandler:用来解决认证过的用户访问无权限资源时的异常,主要跟权限控制相关 自定义AuthenticationEntryPoi
认证服务器默认返回的数据格式如下: { "error": "unsupported_grant_type", "error_description": "Unsupported grant type: passwo
资源服务器相关依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifa
四种授权码模式 授权码模式 密码模式 客户端模式 简化模式 密码模式 grant_type:授权类型,必选,此处固定值“password” username:表示用户名,必选 password:表示用户密码,必选 scope:权限范围,可选 (1)获取access_token http:/
POM相关依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifact
四种授权模式 授权码模式 密码模式 客户端模式 简化模式 密码模式 grant_type:授权类型,必选,此处固定值password username:表示用户名,必选 password:表示用户密码,必选 scope:权限范围,可选 (1)获取access_token http://lo
依赖 <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId&
Filter是容器(Tomcat)级别,HandlerInterceptor是应用级别 因为Filter是作用在Servlet前,Interceptor执行在Controller前,所以正确的处理流程是: Filter前处理 --> Interceptor前处理 --> Control
HTTP返回场景 返回状态:417 Expectation Failed 返回内容: { "object": "error", "code": "charge_id_not_exist", &q
参考:http://stackoverflow.com/questions/13837012/spring-resttemplate-timeout Java Config方式 @Configuration public class RestTemplateConfig { @Bean
应用场景 Spring Boot项目中,我们可能遇到@Autowired注入对象为null的问题,可能的原因包含: (1)当前类的初始化在注入类注入之前 (2)多线程环境,新创建的线程中,是不能自动注入Bean/Service的 此时就需要手动注入Bean 手动获取Bean的工具类 原理,在项目启
Environment方式 @Autowired Environment environment; String profile = environment.getActiveProfiles()[0];
Undertow 在Spring Boot框架中,我们使用最多的是Tomcat,这是Spring Boot默认的容器技术,而且是内嵌式的Tomcat。同时,SpringBoot也支持Undertow容器,我们可以很方便的用Undertow替换Tomcat,而Undertow的性能和内存使用方面都优于
在项目中我们遇到404找不到的错误、或者500服务器错误都需要配置相应的页面给用户一个友好的提示,而在Spring Boot中我们需要如何设置。 我们需要实现ErrorController接口,重写handleError方法。 import org.springframework.boot.aut
Spring Boot“约定大于配置”的特性,体现了优雅流畅的开发过程,其部署启动方式java -jar xxx.jar也很优雅。但是通常使用的停止应用方式是kill -9 进程号,即使写了脚本,还是显得有些粗鲁。这样的应用停止方式,在停止的那一刹那,应用中正在处理的业务逻辑会被中断,导致产生业务异