这个你仔细看他的需求是在没有使用maven的时候构建好了的,这个时候他改掉依赖放在webinf/lib下,我觉得应该是引用以前他放的包,他这是换汤不换药,如果没有配置pom中dependency的话,他还是在使用这些包,如果配置了,那他需要改干嘛!!
转:
maven 项目出现 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
在网上找了些资料,有的说是少jar包,把有关spring的jar包复制到/WEB-INF/lib下面就行了,但这是maven项目,不需要这样做...
还有一个原因是,项目不是maven项目,我这个之前是普通的web项目,只是加上了一个pom.xml而已
需要修改的有两个地方
1.项目根目录下的.project文件,用记事本打开,加入以下代码(把原来的<<SPAN style="COLOR: #800000">buildSpec>节点和<<SPAN style="COLOR: #800000">natures>替换了):
<</SPAN>buildSpec>
<</SPAN>buildCommand>
<</SPAN>name>org.eclipse.wst.jsdt.core.javascriptValidator</</SPAN>name>
<</SPAN>arguments>
</</SPAN>arguments>
</</SPAN>buildCommand>
<</SPAN>buildCommand>
<</SPAN>name>org.eclipse.jdt.core.javabuilder</</SPAN>name>
<</SPAN>arguments>
</</SPAN>arguments>
</</SPAN>buildCommand>
<</SPAN>buildCommand>
<</SPAN>name>org.eclipse.wst.common.project.facet.core.builder</</SPAN>name>
<</SPAN>arguments>
</</SPAN>arguments>
</</SPAN>buildCommand>
<</SPAN>buildCommand>
<</SPAN>name>org.eclipse.wst.validation.validationbuilder</</SPAN>name>
<</SPAN>arguments>
</</SPAN>arguments>
</</SPAN>buildCommand>
<</SPAN>buildCommand>
<</SPAN>name>org.eclipse.m2e.core.maven2Builder</</SPAN>name>
<</SPAN>arguments>
</</SPAN>arguments>
</</SPAN>buildCommand>
<</SPAN>buildCommand>
<</SPAN>name>org.maven.ide.eclipse.maven2Builder</</SPAN>name>
<</SPAN>arguments>
</</SPAN>arguments>
</</SPAN>buildCommand>
</</SPAN>buildSpec>
<</SPAN>natures>
<</SPAN>nature>org.maven.ide.eclipse.maven2Nature</</SPAN>nature>
<</SPAN>nature>org.eclipse.m2e.core.maven2Nature</</SPAN>nature>
<</SPAN>nature>org.eclipse.jem.workbench.JavaEMFNature</</SPAN>nature>
<</SPAN>nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</</SPAN>nature>
<</SPAN>nature>org.eclipse.wst.common.project.facet.core.nature</</SPAN>nature>
<</SPAN>nature>org.eclipse.jdt.core.javanature</</SPAN>nature>
<</SPAN>nature>org.eclipse.wst.jsdt.core.jsNature</</SPAN>nature>
</</SPAN>natures>
2.项目根目录下的.classpath,找到
<</SPAN>classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
替换为:
<</SPAN>classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<</SPAN>attributes>
<</SPAN>attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</</SPAN>attributes>
</</SPAN>classpathentry>
新增加一个classpathentry节点:
<</SPAN>classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<</SPAN>attributes>
<</SPAN>attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</</SPAN>attributes>
</</SPAN>classpathentry>
OK,到这一步已经完成了,到eclipse中刷新项目,然后重新启动tomcat,错误已经解决!
在.classpath文件中:
<</SPAN>classpathentry kind="output" path="target/classes"/>
改为:
<</SPAN>classpathentry kind="output" path="WebContent/WEB-INF/classes"/>
习惯,^_^,把编译后的文件放到WEB-INF/classes下面