天天看点

maven项目启动报错: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener...

转自:点击打开链接(稍有改动)      
tomcat在发布项目的时候没有同时发布maven依赖所添加的jar包,所以找不到。      
解决方法:设置一下eclipse:
右键项目 —> properties -> Deployment Assembly -> Add -> Java Build Path Entries -> 选择Maven Dependencies -> Finish -> OK
把对应的Maven依赖包也发布到tomcat,调试时会自动把那些jar发布到指定目录下,tomcat也能找到那些jar了      
发生错误的一种情况如下:      
web.xml      
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	
	<welcome-file-list>index.jsp</welcome-file-list>
	
	<!-- web容器启动时由ContextLoaderListener自动装配相关配置文件 -->
	
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:dubbo.xml</param-value>
	</context-param>
	
	
</web-app>	
           

转载于:https://www.cnblogs.com/tongrui/p/6376249.html