Die Methode OAuth2AuthorizationServerConfigurer.authorizationServer() von Spring Authorization Server wurde nicht gefundJava

Java-Forum
Anonymous
 Die Methode OAuth2AuthorizationServerConfigurer.authorizationServer() von Spring Authorization Server wurde nicht gefund

Post by Anonymous »

Ich bin neu bei Spring Security. Ich habe versucht, einen Autorisierungsserver zu erstellen, und habe einige Dokumentationen durchgesehen. Ich habe gesehen, dass alle so etwas verwendet haben:

Code: Select all

OAuth2AuthorizationServerConfigurer configurer = OAuth2AuthorizationServerConfigurer.authorizationServer();
Aber wenn ich den gleichen Code in meiner App mache, erhalte ich eine Fehlermeldung, dass die Methode nicht definiert ist.
Meine build.gradle-Datei sieht so aus:

Code: Select all

plugins {
id 'java'
id 'org.springframework.boot' version '4.0.1'
id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
description = 'Auth Server'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-security-oauth2-authorization-server'
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.boot:spring-boot-starter-validation'
testImplementation 'org.springframework.boot:spring-boot-starter-security-oauth2-authorization-server-test'
testImplementation 'org.springframework.boot:spring-boot-starter-security-test'
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
useJUnitPlatform()
}
Hier ist mein vollständiger Code:

Code: Select all

package com.example.auth;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.oauth2.server.authorization.OAuth2AuthorizationServerConfigurer;
import org.springframework.security.web.SecurityFilterChain;

@SpringBootApplication
@EnableWebSecurity
public class AuthApplication {

public static void main(String[] args) {
SpringApplication.run(AuthApplication.class, args);
}

@Bean
@Order(1)
public SecurityFilterChain authorizatFilterChain(HttpSecurity http) throws Exception {
OAuth2AuthorizationServerConfigurer configurer = OAuth2AuthorizationServerConfigurer.authorizationServer();
return http.build();
}

}
Und hier ist die Ausgabe, wenn ich ./gradlew build
ausführe

Code: Select all

$ ./gradlew build

> Task :compileJava FAILED
/home/nous/auth/src/main/java/com/farhadzada/auth/AuthApplication.java:23: error: cannot find symbol
OAuth2AuthorizationServerConfigurer configurer = OAuth2AuthorizationServerConfigurer.authorizationServer();
^
symbol:   method authorizationServer()
location: class OAuth2AuthorizationServerConfigurer
1 error

[Incubating] Problems report is available at: file:///home/nous/auth/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler output below.
/home/nous/auth/src/main/java/com/farhadzada/auth/AuthApplication.java:23: error: cannot find symbol
OAuth2AuthorizationServerConfigurer configurer = OAuth2AuthorizationServerConfigurer.authorizationServer();
^
symbol:   method authorizationServer()
location: class OAuth2AuthorizationServerConfigurer
1 error

* Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with --scan to generate a Build Scan (powered by Develocity).

BUILD FAILED in 1s
1 actionable task: 1 executed

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post