Java 页面尝试使用SpringMVC加载css资源时出现错误500

Java 页面尝试使用SpringMVC加载css资源时出现错误500,java,spring,maven,spring-mvc,thymeleaf,Java,Spring,Maven,Spring Mvc,Thymeleaf,当页面尝试使用SpringMVC加载css资源时,我遇到了错误500。当我尝试在浏览器中打开任何资源时,会显示以下异常: 类型异常报告 消息处理程序调度失败;嵌套异常是 java.lang.NoClassDefFoundError:无法初始化类 org.springframework.web.accept.PathExtensionContentNegotiationStrategy$JafMediaTypeFactory 说明服务器遇到意外情况,导致 阻止它满足请求 例外情况 org.spri

当页面尝试使用SpringMVC加载css资源时,我遇到了错误500。当我尝试在浏览器中打开任何资源时,会显示以下异常:

类型异常报告

消息处理程序调度失败;嵌套异常是 java.lang.NoClassDefFoundError:无法初始化类 org.springframework.web.accept.PathExtensionContentNegotiationStrategy$JafMediaTypeFactory

说明服务器遇到意外情况,导致 阻止它满足请求

例外情况

org.springframework.web.util.NestedServletException:处理程序调度 失败;嵌套异常为java.lang.NoClassDefFoundError:无法 初始化类 org.springframework.web.accept.PathExtensionContentNegotiationStrategy$JafMediaTypeFactory org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:978) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) javaservlet.http.HttpServlet.service(HttpServlet.java:634) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javaservlet.http.HttpServlet.service(HttpServlet.java:741) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

根本原因

java.lang.NoClassDefFoundError:无法初始化类 org.springframework.web.accept.PathExtensionContentNegotiationStrategy$JafMediaTypeFactory org.springframework.web.accept.PathExtensionContentNegotiationStrategy.getMediaTypeForResource(PathExtensionContentNegotiationStrategy.java:156) org.springframework.web.accept.ServletPathExtensionContentNegotiationStrategy.getMediaTypeForResource(ServletPathExtensionContentNegotiationStrategy.java:95) org.springframework.web.servlet.resource.ResourceHttpRequestHandler.getMediaType(ResourceHttpRequestHandler.java:527) org.springframework.web.servlet.resource.ResourceHttpRequestHandler.HandlerRequest(ResourceHttpRequestHandler.java:348) org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) javaservlet.http.HttpServlet.service(HttpServlet.java:634) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javaservlet.http.HttpServlet.service(HttpServlet.java:741) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

下面是在我的页面中调用css的地方:

藻类工厂 通过文件查看页面://-->

pom.xml

4.0.0 com.algaworks brewer 1.0.0-SNAPSHOT 战争 UTF-8
UTF-8 假的 1.8 3.2 4.3.0.1发布 3.1.0 3.0.0.发布
5.2.4.最终版本 -->
4.3.1.最终版本

0.14.0
maven编译器插件
${maven编译器pluging.version}
${java.version}
${java.version}
org.springframework
spring框架bom表
${spring framework.version}
聚甲醛
进口
org.springframework
SpringWebMVC
编撰
javax.servlet
javax.servlet-api
${servlet.version}
假如
org.thymeleaf
百里香
${thymeleaf.version}
编撰
org.thymeleaf
百里香
${thymeleaf.version}
编撰
org.hibernate
休眠验证器
${hibernate validator.version}
编撰
org.glassfish.jaxb
jaxb运行时2.3.2
javax.validation
验证api
1.0.0.GA
和webconfig.xml

包com.algaworks.brewer.config

导入org.springframework.beans.BeansException;进口 org.springframework.context.ApplicationContext;进口 org.springframework.context.ApplicationContextAware;进口 org.springframework.context.annotation.Bean;进口 org.springframework.context.annotation.ComponentScan;进口 org.springframework.context.annotation.Configuration;进口 org.springframework.web.servlet.viewsolver;进口 org.springframework.web.servlet.config.annotation.EnableWebMvc;进口 org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 进口 org.springframework.web.servlet.config.annotation.WebMVCConfigureAdapter; 导入org.thymeleaf.TemplateEngine;进口 org.thymeleaf.spring4.SpringTemplateEngine;进口 org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; 导入org.thymeleaf.spring4.view.thymeleafviewsolver;进口 org.thymeleaf.templatemode.templatemode;进口 org.thymeleaf.templateresolver.ITemplateResolver

导入com.algaworks.brewer.controller.CervejasController

@配置//indica queéuma classe de configuração @ComponentScan(basePackageClasses={CervejasController.class}) //籼稻春玉米作为一种蔬菜 @EnableWebMvc/
   <maven-jaxb2-plugin.version>0.14.0</maven-jaxb2-plugin.version>
     </properties>
 <build>      <plugins>
      <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-pluging.version}</version>
          <configuration>
              <source>${java.version}</source>
              <target>${java.version}</target>
          </configuration>            
      </plugin>       </plugins>   </build>
 <dependencyManagement>       <dependencies>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-framework-bom</artifactId>
          <version>${spring-framework.version}</version>  
          <type>pom</type>
          <scope>import</scope>       
      </dependency>       </dependencies>   </dependencyManagement>
 <dependencies>       <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>  
      <scope>compile</scope>          </dependency>  
      <!-- Servlet API -->    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>${servlet.version}</version>
      <scope>provided</scope>     </dependency>
      <!-- Thymeleaf -->      <dependency>
      <groupId>org.thymeleaf</groupId>
      <artifactId>thymeleaf</artifactId>
      <version>${thymeleaf.version}</version>
      <scope>compile</scope>      </dependency>   
      <dependency>
      <groupId>org.thymeleaf</groupId>
      <artifactId>thymeleaf-spring4</artifactId>
      <version>${thymeleaf.version}</version>
      <scope>compile</scope>      </dependency>
      <!-- Bean Validation / Hibernate Validator-->       <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>${hibernate-validator.version}</version>
      <scope>compile</scope>      </dependency>
      <dependency>
  <groupId>org.glassfish.jaxb</groupId>
  <artifactId>jaxb-runtime</artifactId>       <version>2.3.2</version>    </dependency>       <dependency>
  <groupId>javax.validation</groupId>
  <artifactId>validation-api</artifactId>
  <version>1.0.0.GA</version>     </dependency>       </dependencies>      </project>