关于spring2.5,spring-security2.0升级到 spring3.28 spring-security3.14
1.将原有的spring,spirng-security jar包全部删除掉。
2.建议直接下载完整的spring,和spring-security jar(因为老版本jar在新版本中有可能被拆分为多个。还有可能添加了新的依赖包 ,这样也是为了避免不必要错误出现)
3.修改代码中编译错误问题.
3.1
import org.springframework.security.Authentication;
import org.springframework.security.AuthenticationException;
import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
import org.springframework.security.ui.webapp.AuthenticationProcessingFilter;
这些路径 在新版本的jar中已经变了。需改为新版本的jar。备注:我改的时候 使用到了第三方的jar包, 封装的是 老版本的路径。这个大家要注意,不要忘记改掉(在项目中新建相同路径的类进行重写).如果改动jar包中代码的时候会出现
类头上报The type org.springframework.security.AuthenticationException cannot be resolved. It is indirectly referenced from required .class files
3.2 AuthenticationProcessingFilter 在spring-security3中也被删掉了。我是替换为UsernamePasswordAuthenticationFilter
3.3 public Authentication attemptAuthentication(HttpServletRequest request,HttpServletResponse response),spring-security3新加了HttpServletResponse参数
3.4Configuration problem: You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd schema with Spring Security 3.1. Please update your schema declarations to the 3.1 schema.
Offending resource: file [E:\eclipse\workspace\NAIU\src\main\webapp\WEB-INF\classes\beans\security\component-security.xml]
解决办法:component-security.xml 中命名空间spring-security2.0.xsd 改为 spring-security-3.1.xsd
3.5
Line 27 in XML document from file [E:\eclipse\workspace\NAIU\src\main\webapp\WEB-INF\classes\beans\security\component-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-enumeration-valid: Value 'AUTHENTICATION_PROCESSING_FILTER' is not facet-valid with respect to enumeration
解决办法: 看这个链接 http://blog.csdn.net/runming56/article/details/18032701
注释掉
并在
标签里面新增
备注:
3.6
Configuration problem: The use of "filters='none'" is no longer supported. Please define a separate element for the pattern you want to exclude and use the attribute "security='none'".
解决办法: http://www.educity.cn/wenda/135819.html spring security升级到3.1的一个小问题:不再支持filter="none"了
原
改成
3.7
Cannot resolve reference to bean 'taskService' while setting bean property 'targetObject'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'taskService' defined in file [E:\eclipse\workspace\NAIU\src\main\webapp\WEB-INF\classes\beans\applicationContext-service.xml]: Cannot resolve reference to bean 'exportService' while setting bean property 'exportService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exportService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.cpic.naiu.cpic.service.UserLockService com.cpic.naiu.cpic.service.imp.ExportServiceImpl.userLockService; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint] for bean with name 'authenticationEntryPoint' defined in file [E:\eclipse\workspace\NAIU\src\main\webapp\WEB-INF\classes\beans\security\component-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint
解决办法:org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint 在spring-security3.1 中已经不存在了!改为了org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint
3.8
could not instantiate listener org.springframework.security.ui.session.HttpSessionEventPublisher
java.lang.ClassNotFoundException: org.springframework.security.ui.session.HttpSessionEventPublisher
解决办法: 在web.xml 发现了这个配置,好像是找不到路径了, 替换为
org.springframework.security.web.session.HttpSessionEventPublisher
到此,启动服务成功!还不知道有无运行异常!
3.9
登录后:HTTP ERROR:401 Auuthentication Failed:No AuthenticationProvider found for org.springframework.security.authentication.
UsernamePasswordAuthToken
新增配置
user-service-ref="userDetailsService">
备注:authenticationManager 需要注入到
3.10
2016-03-01 00:44:44.486::WARN: /naiu/upgradeLog.do
java.lang.ClassCastException: org.springframework.util.LinkedCaseInsensitiveMap
at com.cpic.naiu.cpic.repository.imp.UpgradeLogRepositoryImp.find(UpgradeLogRepositoryImp.java:52)
at com.cpic.naiu.cpic.service.imp.UpgradeLogServiceImp.find(UpgradeLogServiceImp.java:29)s
解决办法:
老写法 List listp= jdbcTemplate.queryForList(ps);
ListOrderedMap om = (ListOrderedMap) temp.get(i);
新写法List