oauth2分为资源服务器,授权服务器,具体的oauth2理论及获取token的流程请参看阮一峰老师的文章
https://www.ruanyifeng.com/blog/2019/04/oauth_design.html
https://www.ruanyifeng.com/blog/2019/04/oauth-grant-types.html
引入maven
<!-- https://mvnrepository.com/artifact/org.springframework.security.oauth/spring-security-oauth2 -->
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.5.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>