maven的java web项目启动找不到Spring ContextLoaderListener的解决办法

用maven搭建的java web项目,上传到git仓库后,当同事clone下来项目,部署到tomcat运行时,就报了如下错误,即启动web项目时,加载web.xml文件,找不到spring的监听器,控制台错误如下:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
十月 302015 4:42:36 下午 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Java64\jdk1.7.0_55\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Java64\jdk1.7.0_55\jre\bin;c:\Program Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Java64\jdk1.7.0_55\bin;D:\Program Files\MySQL\MySQL Server 5.5\bin;D:\developer\apache-maven-3.1.1\bin;C:\Program Files\nodejs\;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Users\van\AppData\Local\Android\sdk\platform-tools;C:\Users\van\AppData\Local\Android\sdk\tools;d:\Program Files\Git\cmd;d:\Program Files\Git\mingw64\bin;d:\Program Files\Git\usr\bin;C:\Users\van\AppData\Roaming\npm;.
十月 302015 4:42:36 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host} Setting property 'xmlNamespaceAware' to 'false' did not find a matching property.
十月 302015 4:42:37 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host} Setting property 'xmlValidation' to 'false' did not find a matching property.
十月 302015 4:42:37 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property  'source' to 'org.eclipse.jst.j2ee.server:dsx-app' did not find a matching property.
十月 302015 4:42:37 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
十月 302015 4:42:37 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8019"]
十月 302015 4:42:37 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1064 ms
十月 302015 4:42:37 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
十月 302015 4:42:37 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.53
十月 302015 4:42:38 下午 org.apache.catalina.util.SessionIdGenerator createSecureRandom
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [132] milliseconds.
十月 302015 4:42:38 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4888)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
 
十月 302015 4:42:38 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Skipped installing application listeners due to previous error(s)
十月 302015 4:42:38 下午 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
十月 302015 4:42:38 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/dsx-app] startup failed due to previous errors
十月 302015 4:42:38 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
十月 302015 4:42:38 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8019"]
十月 302015 4:42:38 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 1363 ms

 

这,这个错误真心让人醉了,究竟是怎么回事,我本地是没问题的啊,为什么同事clone下来就出了这种错误。经过半天研究后发现,不知道什么原因,clone下来后用eclipse导入maven项目后,在他那里用git status命令看了一下,有两个配置文件改变了,一个是.classpath,一个是.project,这两个文件内容变了,当我把这两个文件还原为最初状态后,项目就正常了。

虽然这样能够解决,但是终归不太完美,因为以后新人进来还会出现这种问题!

最后终于找到解决方法,感谢原作者,参考http://www.yihaomen.com/article/java/471.htm

解决方法:

1. 右键单击工程项目 ->点击 properties
2. 选择 Deployment Assembly
3. 点击 Add -> Java Build Path Entries -> Next
4. 选择 Maven Dependencies -> Finish -> Apply -> OK
5. Clean project and server. 重启server

posted @ 2018-08-02 09:45  _小豪豪  阅读(483)  评论(0编辑  收藏  举报