ProviderSettings class not found it says Cannot resolve symbol ProviderSettings
Asked Answered
I

2

10

I am new to spring boot space. I am following a tutorial learning to create OAuth authentication server.

While configuring the AuthorizationServerConfig.java the instructor imports 'ProviderSettings' class from package 'org.springframework.security.oauth2.server.authrization.config'

However, I don't have that class available from that particular package.

Am I missing any dependencies? Or is the Class now not available?

Reference 1: Point of error. Cannot resolve symbol ProviderSettings

@Bean
    public ProviderSettings providerSettings(){
        return ProviderSettings.builder()
                .issuer("http://auth-server:9000")
                .build();
    }

Reference 2: pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>np.com.oskarshrestha</groupId>
    <artifactId>Oauth-authorization-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Oauth-authorization-server</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-oauth2-authorization-server</artifactId>
            <version>1.0.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>


I tried to find the correct import for the required class i.e. 'ProviderSettings'
Cross checked dependencies.
Imbibe answered 6/3, 2023 at 6:46 Comment(0)
D
29

You won't believe me but I just solved this issue some minutes ago. Looks like the guide was using an outdated version of spring-security-oauth2-authorization-server and they renamed

ProviderSettings to AuthorizationServerSettings

https://github.com/spring-projects/spring-authorization-server/issues/864

https://github.com/spring-projects/spring-authorization-server/issues/681

https://github.com/spring-projects/spring-authorization-server/issues/986

They should add these changes to the docs or make it more clear IMO

Discant answered 6/3, 2023 at 10:4 Comment(2)
Thank you for the guidance. I replaced ProviderSettings with AuthorizationServerSettings and it worked like a charm. Yup, they should have mentioned it.Imbibe
Isn't standard to mark these old classes as deprecated rather than just quietly renaming them?Habile
G
0

I guess you refer to this guy: https://youtu.be/zvR-Oif_nxg?t=32043 .

Actually he is not very clear in what he is doing, adding boilerplate code.

Anyway you can use the reference guide from Spring, where it is showing a working example for Authorization Server: https://docs.spring.io/spring-authorization-server/reference/getting-started.html#defining-required-components

@Bean
public AuthorizationServerSettings authorizationServerSettings() {
    return AuthorizationServerSettings
            .builder()
            .issuer("http://auth-server:9000")
            .build();
}
Gradin answered 25/6, 2024 at 13:33 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.