Search code examples
springauthenticationspring-securityserverclassnotfoundexception

ProviderSettings class not found it says Cannot resolve symbol ProviderSettings


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.

Solution

  • 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