You can get hold of Spring Security in several ways. You can download a packaged distribution from the main Spring Security page, download individual jars from the Maven Central repository (or a Spring Maven repository for snapshot and milestone releases) or, alternatively, you can build the project from source yourself.

您可以通过多种方式获得Spring Security。您可以从Spring Security主页面下载打包的发行版,从Maven Central存储库(或Spring Maven存储库下载快照和里程碑版本)下载单个jar,或者,您也可以自己从源代码构建项目。
 

2.4.1 Usage with Maven (使用Maven)

A minimal Spring Security Maven set of dependencies typically looks like the following:

最小的Spring Security Maven依赖项通常如下所示:
 
pom.xml
 
<dependencies>
<!-- ... other dependency elements ... -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.2.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.2.10.RELEASE</version>
</dependency>
</dependencies>

If you are using additional features like LDAP, OpenID, etc. you will need to also include the appropriate Section 2.4.3, “Project Modules”.  

如果您正在使用LDAP,OpenID等其他功能,则还需要包含相应的第2.4.3节“项目模块”。

Maven Repositories

All GA releases (i.e. versions ending in .RELEASE) are deployed to Maven Central, so no additional Maven repositories need to be declared in your pom.

所有GA版本(即以.RELEASE结尾的版本)都部署到Maven Central,因此不需要在您的pom中声明其他Maven存储库。
 
If you are using a SNAPSHOT version, you will need to ensure you have the Spring Snapshot repository defined as shown below:
 
如果您使用的是SNAPSHOT版本,则需要确保定义了Spring Snapshot存储库,如下所示:
 
pom.xml. 
 
<repositories>
<!-- ... possibly other repository elements ... -->
<repository>
<id>spring-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>http://repo.spring.io/snapshot</url>
</repository>
</repositories>

If you are using a milestone or release candidate version, you will need to ensure you have the Spring Milestone repository defined as shown below:

如果您使用里程碑或候选发布版本,则需要确保已定义Spring Milestone存储库,如下所示:
 
pom.xml
 
<repositories>
<!-- ... possibly other repository elements ... -->
<repository>
<id>spring-milestone</id>
<name>Spring Milestone Repository</name>
<url>http://repo.spring.io/milestone</url>
</repository>
</repositories>

Spring Framework Bom (良好的spring框架)

Spring Security builds against Spring Framework 4.3.21.RELEASE, but should work with 4.0.x. The problem that many users will have is that Spring Security’s transitive dependencies resolve Spring Framework 4.3.21.RELEASE which can cause strange classpath problems.

Spring Security针对Spring Framework 4.3.21.RELEASE构建,但应该与4.0.x一起使用。许多用户将遇到的问题是Spring Security的传递依赖性解决了Spring Framework 4.3.21.RELEASE,它可能导致奇怪的类路径问题。
 
One (tedious) way to circumvent this issue would be to include all the Spring Framework modules in a <dependencyManagement> section of your pom. An alternative approach is to include the spring-framework-bomwithin your <dependencyManagement> section of your pom.xml as shown below:
 
解决此问题的一种(繁琐)方法是将所有Spring Framework模块包含在pom的<dependencyManagement>部分中。另一种方法是将spring-framework-bom包含在pom.xml的<dependencyManagement>部分中,如下所示:
 
 
pom.xml

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.3.21.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

This will ensure that all the transitive dependencies of Spring Security use the Spring 4.3.21.RELEASE modules.

这将确保Spring Security的所有传递依赖项都使用Spring 4.3.21.RELEASE模块。
 
This approach uses Maven’s "bill of materials" (BOM) concept and is only available in Maven 2.0.9+. For additional details about how dependencies are resolved refer to Maven’s Introduction to the Dependency Mechanism documentation.

这种方法使用Maven的“物料清单”(BOM)概念,仅适用于Maven 2.0.9+。有关如何解析依赖关系的其他详细信息,请参阅Maven的依赖关系机制简介文档。

2.4.2 Gradle

A minimal Spring Security Gradle set of dependencies typically looks like the following:

最小的Spring Security Gradle依赖项集通常如下所示:
 
build.gradle. 
 
dependencies {
compile 'org.springframework.security:spring-security-web:4.2.10.RELEASE'
compile 'org.springframework.security:spring-security-config:4.2.10.RELEASE'
}

 

Gradle Repositories

All GA releases (i.e. versions ending in .RELEASE) are deployed to Maven Central, so using the mavenCentral() repository is sufficient for GA releases.

所有GA版本(即以.RELEASE结尾的版本)都部署到Maven Central,因此使用mavenCentral()存储库足以支持GA版本。
 
repositories {
mavenCentral()
}

If you are using a SNAPSHOT version, you will need to ensure you have the Spring Snapshot repository defined as shown below:

如果您使用的是SNAPSHOT版本,则需要确保定义了Spring Snapshot存储库,如下所示:
 
build.gradle. 
 
repositories {
maven { url 'https://repo.spring.io/snapshot' }
}

 

If you are using a milestone or release candidate version, you will need to ensure you have the Spring Milestone repository defined as shown below:

如果您使用里程碑或候选发布版本,则需要确保已定义Spring Milestone存储库,如下所示:
 
build.gradle. 
 
repositories {
maven { url 'https://repo.spring.io/milestone' }
}

Using Spring 4.0.x and Gradle

By default Gradle will use the newest version when resolving transitive versions. This means that often times no additional work is necessary when running Spring Security 4.2.10.RELEASE with Spring Framework 4.3.21.RELEASE. However, at times there can be issues that come up so it is best to mitigate this using Gradle’s ResolutionStrategy as shown below:

默认情况下,Gradle将在解析传递版本时使用最新版本。这意味着在使用Spring Framework 4.3.21.RELEASE运行Spring Security 4.2.10.RELEASE时,通常不需要额外的工作。但是,有时可能会出现问题,因此最好使用Gradle的ResolutionStrategy来缓解这个问题,如下所示:
 
build.gradle. 
 
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.springframework') {
details.useVersion '4.3.21.RELEASE'
}
}
}

This will ensure that all the transitive dependencies of Spring Security use the Spring 4.3.21.RELEASE modules.

这将确保Spring Security的所有传递依赖项都使用Spring 4.3.21.RELEASE模块。
 
This example uses Gradle 1.9, but may need modifications to work in future versions of Gradle since this is an incubating feature within Gradle.
 
此示例使用Gradle 1.9,但可能需要修改才能在Gradle的未来版本中使用,因为这是Gradle中的孵化功能。
 
 
 
 
 
 
 
 
 

Spring Security(七):2.4 Getting Spring Security的更多相关文章

  1. Spring Cloud实战 | 第九篇:Spring Cloud整合Spring Security OAuth2认证服务器统一认证自定义异常处理

    本文完整代码下载点击 一. 前言 相信了解过我或者看过我之前的系列文章应该多少知道点我写这些文章包括创建 有来商城youlai-mall 这个项目的目的,想给那些真的想提升自己或者迷茫的人(包括自己- ...

  2. Spring Security 3.2.x与Spring 4.0.x的Maven依赖管理

    原文链接: Spring Security with Maven原文日期: 2013年04月24日翻译日期: 2014年06月29日翻译人员: 铁锚 1. 概述 本文通过实例为您介绍怎样使用 Mave ...

  3. Spring MVC 项目搭建 -3- 快速 添加 spring security

    Spring MVC 项目搭建 -3- 快速 添加 spring security 1.添加 spring-sample-security.xml <!-- 简单的安全检验实现 --> & ...

  4. Spring Security 入门(1-6-1)Spring Security - 配置文件解析和访问请求处理

    1.在pom.xml中添加maven坐标 <dependency> <groupId>org.springframework.security</groupId> ...

  5. Spring Security 入门(1-7)Spring Security - Session管理

    参考链接:https://xueliang.org/article/detail/20170302232815082 session 管理 Spring Security 通过 http 元素下的子元 ...

  6. Spring Security 入门(1-3-5)Spring Security - remember me!

    Remember-Me 功能 概述 Remember-Me 是指网站能够在 Session 之间记住登录用户的身份,具体来说就是我成功认证一次之后在一定的时间内我可以不用再输入用户名和密码进行登录了, ...

  7. Spring Security 入门(1-6-2)Spring Security - 内置的filter顺序、自定义filter、http元素和对应的filterChain

    Spring Security 的底层是通过一系列的 Filter 来管理的,每个 Filter 都有其自身的功能,而且各个 Filter 在功能上还有关联关系,所以它们的顺序也是非常重要的. 1.S ...

  8. Spring Security 入门(1-3-2)Spring Security - http元素 - intercept-url配置

    http元素下可以配置登录页面,也可以配置 url 拦截. 1.直接配置拦截url和对应的访问权限 <security:http use-expressions="false" ...

  9. Spring Security 入门(1-4-2)Spring Security - 认证过程之AuthenticationProvider的扩展补充说明

    1.用户信息从数据库获取 通常我们的用户信息都不会向第一节示例中那样简单的写在配置文件中,而是从其它存储位置获取,比如数据库.根据之前的介绍我们知道用户信息是通过 UserDetailsService ...

  10. Spring Security 入门(1-3-1)Spring Security - http元素 - 默认登录和登录定制

    登录表单配置 - http 元素下的 form-login 元素是用来定义表单登录信息的.当我们什么属性都不指定的时候 Spring Security 会为我们生成一个默认的登录页面. 如果不想使用默 ...

随机推荐

  1. 《JavaScript高级程序设计》笔记:在HTML中使用Javascript(二)

    script元素 向html页面中插入js的主要方法就是使用<script>元素.使用<script>元素的方式有两种:直接在页面中嵌入js代码和包含外部js文件.直接在页面中 ...

  2. 2018-05-14 代码考古-Python3官方教程字典例程

    知乎原链 Data Structures中的第一个例程: >>> tel = {'jack': 4098, 'sape': 4139} >>> tel['guido ...

  3. iOS ----------怎么修改xcode默认打开方式

    很简单就能解决:选中文件,右键,显示简介,打开方式,选择8.2.然后打钩.

  4. 轻松搭建Xposed Hook

    0x2.导入xposed库文件XposedBridgeApi-XX.jar,将库文件放在app/lib目录下,自己创建一个lib目录,别放在libs目录下,否则会出错,然后导入库,修改 Scope 为 ...

  5. 我的第一个远程代码库房:建立Github仓库 心得

    一直想有一个自己的代码库,搞了两天终于搞定了,把自己的代码上传到github的愿望终于实现了,虽然仅仅是个开始. 在搭建的过程中,吸收了些知识,记录在这里,以作为分享. Git 和 Github 的区 ...

  6. DataTable表头对不齐、添加参数等方法总结

    tableData: 一:写这篇博客是因为我在网上找到了改变行颜色,没有找到改变td颜色的改变文章,也许好多朋友早就找到了或感觉这个太简单,但不管怎样我还是写下了这篇没有技术含量的一篇. 前提:引入依 ...

  7. RHEL 5.7 使用rpm安装XtraBackup问题总结

    在Red Hat Enterprise Linux Server release 5.7 (Tikanga)上使用RPM方式安装Percona Xtrabackup 2.4.6时遇到了一些问题,特意总 ...

  8. [20181108]with temp as 建立临时表吗.txt

    [20181108]with temp as 建立临时表吗.txt --//链接:http://www.itpub.net/thread-2106304-1-1.html--//作者提到在dg上使用w ...

  9. C#-基本语法(三)

    关键词 关键字,是一些被C#规定了用途的重要单词 在Visual Studio的开发环境中,关键字被标识为蓝色 例如: using:导入命名空间 class:声明类 static:静态 void:无返 ...

  10. 自动化测试基础篇--Selenium iframe定位问题

    摘自https://www.cnblogs.com/sanzangTst/p/7473437.html 有时候我们在定位的途中发现一个现象,元素就在那儿,不离不去,但是我们怎么整就是定不了位,这个时候 ...