Migrating spring 4 from spring 3

来源:互联网 发布:mp4变成mp3软件 编辑:程序博客网 时间:2024/05/17 20:12
今天把Spring从3.2.9升级到了4.3.4,SpringSecurity从3.2.5升级到了4.2.0,下面是升级过程遇到的一些问题:

Spring4 删除了MetadataUtils类,MetadataUtils类中的attributesFor方法移动到了AnnotationConfigUtils中

AuthenticationException 删除了 getAuthentication、setAuthentication 方法,不用即可

LoginUrlAuthenticationEntryPoint 类删除了空构造方法,所以member-authorization-security.xml配置中需要将 p:loginFormUrl="/facade/signin” 改成 <constructor-arg value="/facade/signin" index="0”/> 的形式

UnanimousBased 删除了空构造方法,所以 member-authorization-security.xml 配置中需要将<property name="decisionVoters”> 改成 constructor-arg 的形式

MappingJacksonHttpMessageConverter 被删除了,由 MappingJackson2HttpMessageConverter 替代,需要修改所有用到的servlet-context.xml

spring4 会调用 freemarker.template.Configuration 的带Version参数的构造方法,而freemarker-2.3.20.jar 没有该方法,所以需要升级freemarker版本到至少2.3.21版本,目前升级到了2.3.23

Spring Security 4 会默认开启安全响应头和CSRF,其中CSRF要求POST请求需要额外携带一个token参数,因改动太多,所以关闭了该功能 
0 0
原创粉丝点击