1. SpringSecurityOauth2的授权服务器也支持通过yaml配置文件来配置,不过其token的存储方式只能是基于内存和JWT方式。无需你编写授权服务器配置类。
    1. @EnableAuthorizationServer
    2. @SpringBootApplication
    3. public class DemoApplication {
    4. public static void main(String[] args) {
    5. SpringApplication.run(DemoApplication.class, args);
    6. }
    7. }
    1. 只需要以上方式加上SpringSecurity的一个配置类就可以。<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/1609516/1628513913910-988c92ca-ad90-4897-aa21-f845821249fe.png#clientId=uc1548e8f-6f6a-4&from=paste&height=326&id=ud5fb68ac&margin=%5Bobject%20Object%5D&name=image.png&originHeight=326&originWidth=427&originalType=binary&ratio=1&size=17813&status=done&style=none&taskId=u48ca11e6-994b-4010-865f-17e85c6ccdc&width=427)<br />最后展示一下Yaml的配置:
    1. security:
    2. oauth2:
    3. client:
    4. client-id: gaoxi
    5. client-secret: "123456"
    6. access-token-uri: http://www.baidu.com
    7. scope: read,write
    8. authorized-grant-types: client_credentials,password,refresh_token
    9. authorization:
    10. token-key-access: permitAll()
    11. check-token-access: permitAll()
    12. jwt:
    13. key-value: 123456

    这样就可以使用了。