天天看點

spring security3.24後applicationContext-security.xml中schema配置出錯解決方法

   我在以前的一個老項目中使用的spring security的版本是spring-core-3.0.1.RELEASE.jar,其他的相關依賴的包也是這個版本的,但在我在新的項目中把包的版本更新成了3.24的;使用的配置檔案還是用原來3.01的applicationContext-security.xml-old。

applicationContext-security.xml  --old 版本是3.0.1

上面我隻寫出了schema的限制,但是問題出現了,在新的項目部署到伺服器時報如下錯誤了,

上面中錯誤提到一句很關鍵的

You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd or spring-security-3.1.xsd schema with Spring Security 3.2. Please update your schema declarations

to the 3.2 schema

也就是說我需要把我的schema更新成 3.2 以上的版本,

然後我在官方網站找到一個最新的一個配置檔案:修改成如下就ok了

<a target="_blank" href="http://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/reference/htmlsingle/#ns-config">官方的配置執行個體</a>

applicationContext-security.xml  --new 版本是3.2.4 :

這樣就解決了。

然後額外說一下:在上面錯誤的同時也會報

java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext。

其實大部分情況就是配置檔案不多造成的,

等會 我把完整的項目貼到這兒: