[英]How to enforce a specific Spring Security version dependency in Spring Boot
您如何確保按照此記錄的<\/a>錯誤<\/a>使用 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
如果您使用的是較早的Spring Boot Starter,但您想要最新的安全性,則可以執行以下操作
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
使用Spring Boot時,請使用不同的Spring Boot Starter項目來獲取適當的依賴項。 對於Spring Security,這意味着要添加spring-boot-starter-security
依賴關系以獲得所有必需的Spring Security依賴關系。
使用入門將使您免於追查正確的依賴項和依賴項版本,您將通過這種方式獲得一套有效的依賴項。
我認為這個問題的當前答案可以在這里找到:
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'
在你的 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>
</dependencies>
另請記住,如果您要嘗試公共 Maven 存儲庫中可能不存在的新構建,您可能必須添加 Spring 自己的存儲庫,例如https://repo.spring.io/snapshot
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.