赞
踩
例子基于Spring Boot 2.1.7.RELEASE ,使用mysql数据库
本例中资源服务为独立的应用
参考资源: Resource Server Configuration
ResourceServerConfigurer
接口的实现类且使用@EnableResourceServer
注解进行标注ResourceServerConfigurer
接口有一个实现类ResourceServerConfigurerAdapter
,这里我们继承这个类
/** * Created by liuquan on 2019/8/13. */ @Configuration @EnableResourceServer public class CustomResourceServerConfigurer extends ResourceServerConfigurerAdapter { @Override public void configure(ResourceServerSecurityConfigurer resources) throws Exception { } @Override public void configure(HttpSecurity http) throws Exception { } }
@EnableResourceServer
注解会导入一个配置类ResourceServerConfiguration
protected void configure(HttpSecurity http) throws Exception { ResourceServerSecurityConfigurer resources = new ResourceServerSecurityConfigurer(); ResourceServerTokenServices services = resolveTokenServices(); if (services != null) { resources.tokenServices(services); } else { if (tokenStore != null) { resources.tokenStore(tokenStore); } else if (endpoints != null) { resources.tokenStore(endpoints.getEndpointsConfigurer().getTokenStore()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。