Eclipse IDE开发工具 spring security 和maven,spring,发生jar包冲突和依赖关系问题怎么办:
1:首先用maven命令对项目进行项目转化,(下载jar包)
mvn eclipse:eclipse -Dwtpversion=2.0 运行后再执行
mvn clean install -Dmaven.skip.test=true 进行打包。
若是出现局部错误可能:
(1):prepertities--project facts JDK版本问题 1.4改为1.5,1.6以上
(2):jre错误版本号,或者是没有用本地的jre版本。在preperties-bulidpath-先remove再add library选择本地jre.
2:java.lang.IllegalArgumentException: Document base D:\myeclipse_workerspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\ehp-web does not exist or is not a readable directory
说明ehp-web没有部署成功。、
在 自己的eclipse空间中 D:\myeclipse_workerspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps查看ehp-web是否部署成功了。
解决办法:deployment assembly下
删除红框内的jar包
为什么:个人理解 eclipse 的自动转化jar包有冲突,tomcat无法识别。
3:错误点发生改变如下:文件找不到。将java工程打成的jar包加到D:\myeclipse_workerspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\ehp-web 的lib下:
严重: Error configuring application listener of class com.huahai.ehp.listener.WebAppVisitListener
java.lang.NoClassDefFoundError: com/huahai/ehp/service/IVisitLogService
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3787)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: com.huahai.ehp.service.IVisitLogService
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
第4步:新的问题点:
ERROR(SpringSecurityCoreVersion:35) *** Spring Major version '3' expected, but you are running with version: 2.0. Please check your classpath for unwanted jar files.
ERROR(SpringSecurityCoreVersion:35) *** Spring Major version '3' expected, but you are running with version: 2.0. Please check your classpath for unwanted jar files.
ERROR(SpringSecurityCoreVersion:35) *** Spring Major version '3' expected, but you are running with version: 2.0. Please check your classpath for unwanted jar files.
WARN (SpringSecurityCoreVersion:41) **** You are advised to use Spring 3.0.7.RELEASE or later with this version. You are running: 2.0
WARN (SpringSecurityCoreVersion:41) **** You are advised to use Spring 3.0.7.RELEASE or later with this version. You are running: 2.0
WARN (SpringSecurityCoreVersion:41) **** You are advised to use Spring 3.0.7.RELEASE or later with this version. You are running: 2.0
INFO (SecurityNamespaceHandler:59) Spring Security 'config' module version is 3.1.3.RELEASE
INFO (SecurityNamespaceHandler:59) Spring Security 'config' module version is 3.1.3.RELEASE
INFO (SecurityNamespaceHandler:59) Spring Security 'config' module version is 3.1.3.RELEASE
ERROR(ContextLoader:205) Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate NamespaceHandler for namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [applicationContext.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:57)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:64)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:55)
spring jar包运行的是2.0而不是spring3.07以上,所以出现错误。
原因是:mvn加载jar包时下载了很多2.0版本的jar包,在tomcat集成:D:\myeclipse_workerspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\ehp-web 的lib下
删除不要的jar包。4个:spring-2.0.jar ;spring-dao-2.0-m2.jar;spring-remoting-2.0-m2.jar;spring-support-2.0-m2.jar删除即可。
5步:
ERROR(ContextLoader:318) Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean 'captchaValidationProcessingFilter' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'captchaValidationProcessingFilter' defined in class path resource [applicationContext-security.xml]: Cannot resolve reference to bean 'captchaService' while setting bean property 'captchaService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'captchaService' defined in class path resource [applicationContext-security.xml]: Cannot resolve reference to bean 'imageCaptchaService' while setting bean property 'jcaptchaService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'imageCaptchaService' defined in class path resource [applicationContext-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.octo.captcha.service.image.DefaultManageableImageCaptchaService]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.octo.captcha.service.captchastore.CaptchaStore.initAndStart()V
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
出现此问题是因为jcaptcha-1.0.jar;jcaptcha-api-1.0.jar;jcaptcha-all-1.0-RC6.jar;
删除前两个jar包。
6步:
org.apache.catalina.core.ApplicationContext log
严重: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
at java.lang.Class.getDeclaredConstructors0(Native Method)
解决办法:加入commons-fileupload-1.2.2.jar;commons-io-2.2.jar。即可。
经过6步法则,终于大功告成。