如下是Spring Security 4.0的新特性php
<intercept-url pattern="/**" access="hasRole('ROLE_USER')"/>
如今,咱们能够选择省略掉ROLE_前缀。具体而言,不管ROLE_是否存在,表达式hasRole已经定义了一个做为role的值。咱们能够像下面这样配置(效果和以前同样):html
<intercept-url pattern="/**" access="hasRole('USER')"/>
相似的,也能够像下面同样配置:html5
@PreAuthorize("hasRole('ROLE_USER')")
@PreAuthorize("hasRole('USER')")
做为一个新版本,Spring Security团队作了主要的更新:git
如下是更新的完整详情,或者在JIRA中查看变更:github
能够在github上查看web
Spring Security 4须要Spring 4。而Spring Security 3.2.x 能够在Spring 3.2.x and Spring 4上运做。spring
详细介绍参见安全
如下列出了一些官方再也不建议使用的配置,详情能够参考这里:websocket
Maven:mvc
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-bom</artifactId> <version>4.0.0.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
不要忘记更新依赖
<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>4.0.0.RELEASE</version> </dependency>
详情参考这里: