我在以前的一个老项目中使用的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。
其实大部分情况就是配置文件不多造成的,
等会 我把完整的项目贴到这儿: