Spring Framework 的 spring-core 和 Spring Security 兼容版本

Spring Framework 的 spring-core 和 Spring Security 兼容版本

Spring Framework 的 spring-core 和 Spring Security 的版本需要保持兼容性,尤其是在旧版本(如 Spring 4.x)中。以下是它们的版本对应关系:


Spring 4.x (spring-core 4.x) 对应的 Spring Security 版本

Spring Framework (spring-core)Spring Security 兼容版本备注
4.0.x3.2.x最低要求 Spring Security 3.2.0
4.1.x3.2.x - 4.0.x4.0.x 是 Spring 4.1+ 的推荐版本
4.2.x4.0.x - 4.1.x4.1.x 支持更多新特性
4.3.x (Spring Boot 1.4-1.5)4.1.x - 4.2.x推荐 4.2.x

注意:Spring Security 4.x 仍然兼容 Spring Framework 4.x,但 Spring Security 5.x 需要 Spring 5+。


Spring 5.x (spring-core 5.x) 对应的 Spring Security 版本

Spring Framework (spring-core)Spring Security 兼容版本
5.0.x5.0.x
5.1.x5.1.x - 5.2.x
5.2.x5.2.x - 5.3.x
5.3.x (Spring Boot 2.4+)5.4.x - 5.6.x
6.x6.x

常见组合示例

  1. Spring Boot 1.5.x (Spring 4.3.x)

    • spring-core: 4.3.x
    • spring-security: 4.2.x(推荐)
    • Maven 依赖示例:
      <dependency>
          <groupId>org.springframework.security</groupId>
          <artifactId>spring-security-web</artifactId>
          <version>4.2.18.RELEASE</version>
      </dependency>
      
  2. Spring Boot 2.7.x (Spring 5.3.x)

    • spring-core: 5.3.x
    • spring-security: 5.7.x
    • Maven 依赖示例:
      <dependency>
          <groupId>org.springframework.security</groupId>
          <artifactId>spring-security-web</artifactId>
          <version>5.7.10</version>
      </dependency>
      

如何检查版本兼容性?

  1. Spring Security 官方文档
    参考 Spring Security Releases官方文档
  2. Spring Boot 的依赖管理
    如果使用 Spring Boot,可以直接继承其管理的版本(无需手动指定):
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.22.RELEASE</version> <!-- 或 2.x.x -->
    </parent>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    

总结

  • Spring 4.x → 使用 Spring Security 3.2.x - 4.2.x(推荐 4.2.x)。
  • Spring 5.x → 使用 Spring Security 5.x
  • Spring 6.x → 必须使用 Spring Security 6.x

如果需要更精确的版本,建议查阅 Spring Security 官方兼容性文档

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值