如何在 Spring Boot 中强制执行特定的 Spring Security 版本依赖

eco*_*coe 3 java spring spring-mvc intellij-idea maven

如何确保按照此记录错误使用 Spring Security >3.2.1 ?:

class path resource [org/springframework/security/config/annotation/authentication/configurers/GlobalAuthenticationConfigurerAdapter.class] 
cannot be opened because it does not exist
Run Code Online (Sandbox Code Playgroud)

我尝试在我的系统中升级它POM.xml,但没有成功(Intellij抱怨该版本不存在):

在此输入图像描述

我在 Intellij Maven 设置中的本地存储库路径是正确的。我将鼠标悬停在其投诉上并选择“更新 Maven 索引”。它尝试更新我的本地存储库,仅返回依赖项不存在。

那么,我还能如何确保找到GlobalAuthenticationConfigurerAdapter.class呢?

fas*_*xes 8

我认为这个问题的当前答案可以在这里找到:

摇篮

https://docs.spring.io/spring-security/reference/getting-spring-security.html#getting-gradle-boot

例如,对于 Spring Security 版本 5.7.0-SNAPSHOT 指定属性

ext['spring-security.version']='5.7.0-SNAPSHOT'
Run Code Online (Sandbox Code Playgroud)

在你的 Gradle 文件中

梅文

https://docs.spring.io/spring-security/reference/getting-spring-security.html#getting-maven-boot

例如,对于 Spring Security 版本 5.7.0-SNAPSHOT 指定属性

<properties>
    <!-- ... -->
    <spring-security.version>5.7.0-SNAPSHOT</spring-security.version>
</properties>
Run Code Online (Sandbox Code Playgroud)

另请记住,如果您要尝试公共 Maven 存储库中可能不存在的新构建,您可能必须添加 Spring 自己的存储库,例如https://repo.spring.io/snapshot.