【问题标题】:Please advice to me that Spring MVC Error请告诉我 Spring MVC 错误
【发布时间】:2017-08-02 06:41:56
【问题描述】:

我不知道出了什么问题。

我将附上来源和建议,告诉我为什么会发生错误..

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 

我不知道为什么会出错。

请告诉我如何解决问题。

【问题讨论】:

  • 我认为topic 应该对您有所帮助。您需要将 spring 核心添加到依赖项。
  • 我也有这种依赖。但我的 pom.xml 的 spring-core 版本是 4.1.6 .. 我修改版本它是工作。不同版本有区别吗?
  • 是的,SynthesizingMethodParameter 仅在 Spring 4.2 中引入。

标签: spring spring-mvc dependency-injection


【解决方案1】:

有一个NoClassDefFoundError,我想你没有包括spring-core。以下是应添加到pom.xml 的缺失依赖项:

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

【讨论】:

  • 我也有这种依赖。但我的 pom.xml 的 spring-core 版本是 4.1.6 .. 我修改了版本。这是工作。不同版本有区别吗?
  • 是的。错误中的此类SynthesizingMethodParameter仅在4.2版本中添加。
  • 如果问题已解决 - 您是否可以检查此问题是否已回答,以免为您粘贴更多答案,因为此问题目前仍处于开放状态:)
【解决方案2】:

您需要在 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>

【讨论】:

  • 我也有这种依赖。但我的 pom.xml 的 spring-core 版本是 4.1.6 .. 我修改版本它是工作。不同版本有区别吗?
  • 显然有... 如果您有时间,您可以查看更改日志。如果我不得不猜测该类必须在 4.1.6 之后更改或引入
猜你喜欢
  • 2012-07-24
  • 1970-01-01
  • 2020-08-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多