我在Eclipse中尝试基本的Spring项目,当我启动tomcat时出现以下错误。
java.lang.NoSuchFieldError: APPLICATION_CONTEXT_ID_PREFIX
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:454)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:483)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:358)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:325)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
我知道这是因为JAR冲突,我尝试删除其中大部分但无法解决它。任何人都可以帮我解决它。
我正在使用Spring 2.5和Servlet 2.4。当前在项目类路径中的jar如下:
<classpathentry kind="lib" path="war/WEB-INF/lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/junit.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/standard.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/jstl-1.2.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/spring-web-servlet.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/spring-context-2.5.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/spring-webmvc-2.5.5.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/org.springframework.beans.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/spring-2.5.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/org.springframework.core-2.5.5.a.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/javax.servlet.jar"/>