gpt4 book ai didi

java - Spring Boot REST API 应用程序看不到 OAuth2 库

转载 作者:行者123 更新时间:2023-12-02 11:26:28 26 4
gpt4 key购买 nike

我想使用 OAuth2 通过身份验证来保护我的 REST API,但在我的旅程开始时,我遇到了一些问题,例如 “无法解析符号 'AuthorizationServerConfigurerAdapter'” 在互联网上找不到任何解决方案所以我问你。我根本无法导入它,并且我写了类似 import org.springframework.security.oauth2.client.OAuth2ClientContext; 的内容,它说无法解析 oauth2。

我的 pom.xml 文件看起来像:

<groupId>com.bsuir</groupId>
<artifactId>buspark</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>buspark</name>
<description>labs</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>

<!--SECURITY-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth2</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
<!--SECURITY-->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!--SWAGGER-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
<!--SWAGGER-->



<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

提前致谢。

最佳答案

组 ID 包含错误。必须是没有2的oauth。最终版本如下所示:

<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.6.RELEASE</version>
</dependency>

关于java - Spring Boot REST API 应用程序看不到 OAuth2 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49592281/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com