Initially, before enabling Spring Security OAuth2, the dependency and configuration classes need to be specified. The following Maven starter dependency needs to be included:
<dependencies>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
...
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>
</dependencies>
The preceding entries will import all dependencies related to Spring Security and Spring Security OAuth2. Now, let's look at the configuration.