spring-security-oauth2 与 spring-cloud-starter-oauth2

spring-security-oauth2 vs spring-cloud-starter-oauth2

我正在使用 spring boot 构建一个 oAuth2 应用程序。但是,Github 中有各种示例项目使用 spring-security-oauth2spring-cloud-starter-oauth2
我们是否有特定的场景可以在应用程序中使用特定的 jar?

虽然Spring云主要用于分布式系统。即使是非分布式应用程序,在 Github 上也有很多使用 spring-cloud-starter-oauth2 的实现。谢谢。

为了解决复杂的依赖管理问题,Spring 引入了启动器。 Starter POM 是一组依赖项描述符(将多个常用的依赖项组合到一个 POM 中),否则您也可以手动将其单独包含在您的应用程序中。 Starters 可用于 Web、测试、数据 jpa、安全、邮件等。不是starter就是module:一个简单的神器

如果你想使用 web,你可以自己(手动)包含 tomcat、mvc 和 jackson - 一个简单的应用程序有很多依赖项。相反,您只需引入一个入门依赖项:

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

回答你的问题:

spring-security-oauth2 是组 org.springframework.security.oauth 的工件,它支持 oAuth2(仅)对于 Spring 安全性(不是云),而 spring-cloud-starter-oauth2 是一组多个依赖项,如上面的入门 Web 依赖项。这是 Spring 云的 OAuth2 启动器,仅当您使用 Spring 云时才适用。这个启动器在 OAuth2 框架下附带了开箱即用的依赖包,用于 Spring 像 SSO、OAuth2 客户端这样的云。

Spring 最初将 oauth2 移至 spring 云启动,但从版本 2.4.0.M1 开始,它已移至 spring 安全。您将能够在 start.spring.io 上验证 oauth2 云依赖仅在版本 >=2.0.0.RELEASE 和 <2.4.0.M1