2017-08-02 86 views
0

我不知道出了什麼問題。請教我,Spring MVC錯誤

我會附上的來源和意見,我爲什麼錯誤發生的事情..

的pom.xml

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-webmvc</artifactId> 
    <version>4.3.8.RELEASE</version> 
    </dependency> 

是錯誤代碼

org.springframework.beans.factory.BeanInitializationException: Error loading DispatcherServlet's default strategy class [org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver] for interface [org.springframework.web.servlet.HandlerExceptionResolver]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/annotation/SynthesizingMethodParameter 
    at org.springframework.web.servlet.DispatcherServlet.getDefaultStrategies(DispatcherServlet.java:830) 
    at org.springframework.web.servlet.DispatcherServlet.initHandlerExceptionResolvers(DispatcherServlet.java:669) 
    at org.springframework.web.servlet.DispatcherServlet.initStrategies(DispatcherServlet.java:489) 
    at org.springframework.web.servlet.DispatcherServlet.onRefresh(DispatcherServlet.java:476) 
    at org.springframework.web.servlet.FrameworkServlet.onApplicationEvent(FrameworkServlet.java:806) 
    at org.springframework.web.servlet.FrameworkServlet$ContextRefreshListener.onApplicationEvent(FrameworkServlet.java:1121) 
    at 

我不知道爲什麼我得到一個錯誤。

請讓我知道如何解決這個問題。

+1

我覺得這個[專題](https://stackoverflow.com/questions/33988668/exception-in-spring-mvc)應該幫助你。您需要將Spring核心添加到依賴項。 –

+0

我也有這種依賴。但我的pom.xml的彈簧核心版本是4.1.6 ..我修改它的工作版本。不同版本之間有區別嗎? –

+1

是的,'SynthesizingMethodParameter'只在Spring 4.2中引入。 –

回答

2

有一個NoClassDefFoundError,我想你不包括spring-core。下面是缺少的依賴應該被添加到pom.xml

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-core</artifactId> 
    <version>4.3.8.RELEASE</version> 
</dependency> 
+0

之後的類必須已經被更改或引入,我也有這種依賴關係。但我的pom.xml有spring-core版本是4.1.6 ..我修改了版本。這是工作。不同版本之間有區別嗎? –

+1

是的。該錯誤類中的'SynthesizingMethodParameter'僅在版本4.2中添加。 –

+1

如果問題解決了 - 你可以檢查這個問題的答案爲了不粘貼更多的答案給你,因爲這個問題目前保持開放:) –

1

你需要在你的pom.xml中添加一個依賴到spring-core。下面的片段應該解決您的問題:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-core --> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-core</artifactId> 
    <version>4.3.8.RELEASE</version> 
</dependency> 
+0

我也有這種依賴性。但我的pom.xml的彈簧核心版本是4.1.6 ..我修改它的工作版本。不同版本之間有區別嗎? –

+1

顯然有...你可以檢查更改日誌,如果你有時間。如果我必須猜測4.1.6 –