HTTP Status 500 - Servlet.init() for servlet springMVC threw exception
type Exception report
message Servlet.init() for servlet springMVC threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet springMVC threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620) org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2476) org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2465) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745)
root cause
java.lang.NoSuchMethodError: org.springframework.core.io.ResourceEditor.(Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/PropertyResolver;)V org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620) org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2476) org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2465) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.62 logs.
上面是访问mvc后出现的报错信息
网上对于这段异常的解释最为接近的是:jar的冲突 。
我得到解决突破的最后一个查阅:
http://stackoverflow.com/questions/18140387/java-lang-nosuchmethoderror-org-springframework-core-io-resourceeditor-init
3 down vote | Any time I get those kinds of Method Not Found exceptions inside frameworks (especially mature ones) the first thing I do is to look for conflicting dependencies. Sometimes two different libraries include different versions of the same dependency which, in my experience, commonly causes this type of issue. |
up vote 3 down vote | Your Servlet has a Spring 3 dependency (where the ResourceEditor(ResourceLoader,PropertyResolver) constructor is present) but you use a Spring 2 library where no such constructor is available! |
然后我开始检查自己的依赖管理和最终target下lib中的jar包:
发现如图:
target的lib目录中也有此jar包。
我首先把这个spring:2.5.6SEC03.jar 从lib中删除,
再次启动项目访问, ok,O(∩_∩)O 可以正常访问了。
然后分析为什么会突然多了这么个东西:
查看依赖管理,如上图,其他我的pom文件中是没有此依赖添加的。
那么就只可能是此module本身创建是的环境里就带上了这么个东西,所以我查看项目构建环境
打开 file > project structure: (这个地带jar包的截图我之前查找问题时复制的工程里截的,上面那个工程我已经解决)
崩溃。。。
说明项目构建这一块还是太嫩了。。
勾选然后删除,点击应用即可!