2015-07-20 170 views
2

問題: 我得到這個錯誤:java.lang.NoSuchFieldError的:STANDARD_NUMBER_TYPES

java.lang.NoSuchFieldError: STANDARD_NUMBER_TYPES

情況: 我嘗試添加彈簧JPA春季數據JPA和與此配置調度員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"/> 

我越來越黃exlamation標誌(在線路:)

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

,上面寫着:

Unable to locate Spring NamespaceHandler for element 'jpa:repositories' of schema namespace ' 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(上最新版本),我只是在服務器啓動時結束收到此錯誤:

root cause 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> 
+0

檢查班NumberUtils – andy

+0

謝謝安迪!檢查這個類讓我去https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/util/NumberUtils.java這讓我想到了我有** spring-core **依賴...我沒有,所以這是解決方案。 – efem

回答

0

更改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"> 
+0

似乎沒有工作 – webjockey

+0

你確定嗎?它甚至不是有效的XML。 –

+0

感謝您的支持,我現在糾正了它。我建議在xml中替換xsi:schemaLocation並嘗試一下。 –

0

這可能是因爲你有你的構建重複春天庫。

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