Spring

Spring Security OAuth2认证资源服务器异常处理

Spring Security OAuth2认证资源服务器异常处理

两个异常处理的接口 AuthenticationEntryPoint:用来解决匿名用户访问无权限资源时的异常,也就是跟token相关的资源异常 AccessDeniedHandler:用来解决认证过的用户访问无权限资源时的异常,主要跟权限控制相关 自定义AuthenticationEntryPoi

Joe.Ye Joe.Ye 2023-03-20
0 0 0
Spring Security OAuth2 认证服务器自定义异常处理

Spring Security OAuth2 认证服务器自定义异常处理

认证服务器默认返回的数据格式如下: { "error": "unsupported_grant_type", "error_description": "Unsupported grant type: passwo

Joe.Ye Joe.Ye 2023-03-20
0 0 0
Spring Security OAuth2 Redis 资源服务器配置

Spring Security OAuth2 Redis 资源服务器配置

资源服务器相关依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifa

Joe.Ye Joe.Ye 2023-03-19
0 0 0
Spring Security OAuth2 Redis 模式下认证服务器

Spring Security OAuth2 Redis 模式下认证服务器

四种授权码模式 授权码模式 密码模式 客户端模式 简化模式 密码模式 grant_type:授权类型,必选,此处固定值“password” username:表示用户名,必选 password:表示用户密码,必选 scope:权限范围,可选 (1)获取access_token http:/

Joe.Ye Joe.Ye 2023-03-19
0 0 0
Spring Security OAuth2 JWT 资源服务器配置

Spring Security OAuth2 JWT 资源服务器配置

POM相关依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifact

Joe.Ye Joe.Ye 2023-03-19
0 0 0
Spring Security OAuth2 JWT 认证服务器配置

Spring Security OAuth2 JWT 认证服务器配置

四种授权模式 授权码模式 密码模式 客户端模式 简化模式 密码模式 grant_type:授权类型,必选,此处固定值password username:表示用户名,必选 password:表示用户密码,必选 scope:权限范围,可选 (1)获取access_token http://lo

Joe.Ye Joe.Ye 2023-03-19
0 0 0
Spring Boot接收并响应xml

Spring Boot接收并响应xml

依赖 <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId&

Joe.Ye Joe.Ye 2023-03-19
0 0 0
Spring Boot中HandlerInterceptor和Filter区别及使用

Spring Boot中HandlerInterceptor和Filter区别及使用

Filter是容器(Tomcat)级别,HandlerInterceptor是应用级别 因为Filter是作用在Servlet前,Interceptor执行在Controller前,所以正确的处理流程是: Filter前处理 --> Interceptor前处理 --> Control

Joe.Ye Joe.Ye 2023-03-19
0 0 0
Spring Boot RestTemplate 自定义返回码异常处理

Spring Boot RestTemplate 自定义返回码异常处理

HTTP返回场景 返回状态:417 Expectation Failed 返回内容: { "object": "error", "code": "charge_id_not_exist", &q

Joe.Ye Joe.Ye 2023-03-19
0 0 0
Spring Boot设置RestTemplate的超时时间

Spring Boot设置RestTemplate的超时时间

参考:http://stackoverflow.com/questions/13837012/spring-resttemplate-timeout Java Config方式 @Configuration public class RestTemplateConfig { @Bean

Joe.Ye Joe.Ye 2023-03-19
0 0 0
Spring Boot手动注入Bean

Spring Boot手动注入Bean

应用场景 Spring Boot项目中,我们可能遇到@Autowired注入对象为null的问题,可能的原因包含: (1)当前类的初始化在注入类注入之前 (2)多线程环境,新创建的线程中,是不能自动注入Bean/Service的 此时就需要手动注入Bean 手动获取Bean的工具类 原理,在项目启

Joe.Ye Joe.Ye 2023-03-11
0 0 0
Spring Boot获取profile值

Spring Boot获取profile值

Environment方式 @Autowired Environment environment; String profile = environment.getActiveProfiles()[0];

Joe.Ye Joe.Ye 2023-03-11
0 0 0
Spring Boot弃用Tomcat选择Undertow作为容器

Spring Boot弃用Tomcat选择Undertow作为容器

Undertow 在Spring Boot框架中,我们使用最多的是Tomcat,这是Spring Boot默认的容器技术,而且是内嵌式的Tomcat。同时,SpringBoot也支持Undertow容器,我们可以很方便的用Undertow替换Tomcat,而Undertow的性能和内存使用方面都优于

Joe.Ye Joe.Ye 2023-03-11
0 0 0
Spring Boot 实现ErrorController接口处理404、500等错误页面

Spring Boot 实现ErrorController接口处理404、500等错误页面

在项目中我们遇到404找不到的错误、或者500服务器错误都需要配置相应的页面给用户一个友好的提示,而在Spring Boot中我们需要如何设置。 我们需要实现ErrorController接口,重写handleError方法。 import org.springframework.boot.aut

Joe.Ye Joe.Ye 2023-03-11
0 0 0
Spring Boot 2.0 之优雅停机

Spring Boot 2.0 之优雅停机

Spring Boot“约定大于配置”的特性,体现了优雅流畅的开发过程,其部署启动方式java -jar xxx.jar也很优雅。但是通常使用的停止应用方式是kill -9 进程号,即使写了脚本,还是显得有些粗鲁。这样的应用停止方式,在停止的那一刹那,应用中正在处理的业务逻辑会被中断,导致产生业务异

Joe.Ye Joe.Ye 2023-03-11
0 0 0
1 9 10 11 12 13 16