【问题标题】:java.lang.NoSuchFieldError: STANDARD_NUMBER_TYPESjava.lang.NoSuchFieldError: STANDARD_NUMBER_TYPES
【发布时间】:2015-10-10 02:18:19
【问题描述】:

问题: 我收到了这个错误:

java.lang.NoSuchFieldError: STANDARD_NUMBER_TYPES

情况: 我正在尝试为 Spring Data JPA 添加 spring-jpa 并使用 dispatcher-servlet.xml 的配置

 <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:jpa="http://www.springframework.org/schema/data/jpa"
        xsi:schemaLocation="  
    http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
    http://www.springframework.org/schema/context  
    http://www.springframework.org/schema/context/spring-context-3.0.xsd  
    http://www.springframework.org/schema/tx  
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
    http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd">
...
<jpa:repositories base-package="pl.test.library.dao"/>

我得到黄色感叹号(在线:)

<jpa:repositories base-package="pl.test.library.dao"/>

说:

无法找到元素的 Spring NamespaceHandler 架构命名空间的“jpa:repositories” 'http://www.springframework.org/schema/data/jpa'

所以我敢打赌缺少一些依赖项。添加后:

<dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.8.1.RELEASE</version>
        </dependency>

并尝试启动 apache(最新版本)我在服务器启动结束时收到此错误:

根本原因 java.lang.NoSuchFieldError: STANDARD_NUMBER_TYPES org.springframework.web.context.request.ServletRequestAttributes.(ServletRequestAttributes.java:55) org.springframework.web.servlet.FrameworkServlet.buildRequestAttributes(FrameworkServlet.java:1032) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:959) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858) javax.servlet.http.HttpServlet.service(HttpServlet.java:618) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

还尝试添加以下不同的组合,但也没有运气:

 <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons-core</artifactId>
            <version>1.4.1.RELEASE</version>
        </dependency>
 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>4.1.7.RELEASE</version>
</dependency>

【问题讨论】:

标签: java spring spring-mvc nosuchfieldexception


【解决方案1】:

这可能是因为您的构建中有重复的 spring 库。

如果您使用 Intellj,您可以检查您的 out/artifacts/.._war_exploded/WEB-INF/lib 目录。

【讨论】:

    【解决方案2】:

    更改 shcemaLocation,架构位置似乎是这里的问题。

    来自

    xsi:schemaLocation="  
        http://www.springframework.org/schema/beans  
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
        http://www.springframework.org/schema/context  
        http://www.springframework.org/schema/context/spring-context-3.0.xsd  
        http://www.springframework.org/schema/tx  
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/data/jpa
        http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd">
    

     xsi:schemaLocation="  
        http://www.springframework.org/schema/beans  
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
        http://www.springframework.org/schema/context  
        http://www.springframework.org/schema/context/spring-context-3.0.xsd  
        http://www.springframework.org/schema/tx  
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/data/jpa
        http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
    

    【讨论】:

    • 你确定吗?它甚至看起来都不是有效的 XML。
    • 感谢收看,我现在更正了。我建议替换 xml 中的 xsi:schemaLocation 并尝试一下。
    猜你喜欢
    • 2013-06-05
    • 2013-01-04
    • 2020-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-04
    • 2014-11-04
    相关资源
    最近更新 更多