通过代码生成器生成address相关文件并引入2个配置类ResourceServerConfig和TokenDecode
引入ResourceServerConfig后就必须要公钥和密钥才能使用没放行的方法
引入TokenDecode后就可以使用TokenDecode.getUserInfo().get("username")来获得加密中的用户名
public.key在下载中
ResourceServerConfig代码:
package com.zb.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
import java.io.BufferedReader;
impo