spring security環(huán)境搭建
目前Spring官方只提供Maven的下載方式。但在http://maven.springframework.org中有SpringSecurity及其他所有Spring產(chǎn)品的下載方式。
http://maven.springframework.org/release/org/springframework/中有Spring相關(guān)的所有下載,但好像直到3.2版的,最新的版本在這個(gè)里面找不到
http://maven.springframework.org/release/org/springframework/security/spring-security/3.2.0.RELEASE/這個(gè)是SpringSecurity3.2的下載地址
Maven下載地址:
<dependencies> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>3.2.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>3.2.0.RELEASE</version> </dependency> </dependencies>
本教程是基于SpringMVC3.2+Hibernate4+JPA2.0+SpringSecurity3.2的環(huán)境。SpringMVC3.2+Hibernate4+JPA2.0環(huán)境的搭建在這里就不多說(shuō)了,主要講下SpringSecurity的環(huán)境搭建
web.xml配置
<!-- 加載Spring的配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:applicationContext.xml, classpath:applicationContext-security.xml </param-value> </context-param> <!-- SpringSecurity 核心過(guò)濾器配置 --> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
applicationContext-security.xml命名空間配置,官方提供了兩種配置方案
第一種、命名空間用beans開(kāi)頭,但是在配置中一直需要用<security:*>來(lái)配置。
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> ... </beans>
第二種、命名空間用security開(kāi)頭,在配置中不需要security前綴,但是bean的配置需要用<beans:bean>配置。
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> ... </beans:beans>
到此為止SpringSecurity的環(huán)境配置已基本完成
命名空間的配置可在spring的官方文檔,第4章 Security Namespace Configuration 中找到,一下附上鏈接地址
http://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/reference/htmlsingle/#ns-config
總結(jié)
以上所述是小編給大家介紹的spring security環(huán)境搭建,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
JavaFx實(shí)現(xiàn)登錄成功跳轉(zhuǎn)到程序主頁(yè)面
這篇文章主要為大家詳細(xì)介紹了JavaFx實(shí)現(xiàn)登錄成功跳轉(zhuǎn)到程序主頁(yè)面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06SpringBoot項(xiàng)目War包部署無(wú)法注冊(cè)到Nacos中的解決
這篇文章主要介紹了SpringBoot項(xiàng)目War包部署無(wú)法注冊(cè)到Nacos中的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-01-01解決spring boot2集成activiti6踩過(guò)的坑
這篇文章主要介紹了解決spring boot2集成activiti6踩過(guò)的坑,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-09-09Java如何實(shí)現(xiàn)簡(jiǎn)單后臺(tái)訪問(wèn)并獲取IP
這篇文章主要介紹了Java如何實(shí)現(xiàn)簡(jiǎn)單后臺(tái)訪問(wèn)并獲取IP,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-10-10本地啟動(dòng)RocketMQ未映射主機(jī)名產(chǎn)生的超時(shí)問(wèn)題最新解決方案
這篇文章主要介紹了本地啟動(dòng)RocketMQ未映射主機(jī)名產(chǎn)生的超時(shí)問(wèn)題,本文給大家分享最新解決方案,感興趣的朋友跟隨小編一起看看吧2024-02-02Java 隊(duì)列實(shí)現(xiàn)原理及簡(jiǎn)單實(shí)現(xiàn)代碼
這篇文章主要介紹了Java 隊(duì)列實(shí)現(xiàn)原理及簡(jiǎn)單實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下2016-10-10