【问题标题】:spring-security-oauth2 vs spring-cloud-starter-oauth2spring-security-oauth2 vs spring-cloud-starter-oauth2
【发布时间】:2019-04-29 05:25:25
【问题描述】:

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

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

【问题讨论】:

    标签: spring-boot oauth-2.0 spring-cloud spring-security-oauth2


    【解决方案1】:

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

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

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

    回答你的问题:

    spring-security-oauth2 是组 org.springframework.security.oauth 的工件,它支持 Spring Security(非云)的 oAuth2(仅),而 spring-cloud-starter-oauth2 是一组多个依赖项,就像上面的 starter web 依赖项一样。这是 Spring Cloud 的 OAuth2 启动器,仅当您使用 Spring Cloud 时才适用。这个启动器在 Spring Cloud 的 OAuth2 框架下附带了一系列开箱即用的依赖项,例如 SSO、OAuth2 客户端。

    【讨论】:

    • “这个启动器附带了一系列开箱即用的依赖包......”。比如你怎么知道的?这在哪里提到,我找不到任何关于它的信息。我在哪里可以找到包含的软件包
    • @Alexander Spring 最初将 oauth2 移至 spring cloud started,但从 2.4.0.M1 版本开始,它已移至 spring security。您将能够在 start.spring.io 上验证 oauth2 云依赖项仅在版本 >=2.0.0.RELEASE 和 中
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2021-05-07
      • 2020-07-04
      • 2019-09-25
      • 2017-09-11
      • 2019-04-28
      • 2015-11-14
      • 2016-07-12
      • 2017-01-18
      • 2012-12-19
      相关资源
      最近更新 更多