2013-03-13 61 views
6

我的品牌新的Spring Web服務,我不斷收到此錯誤:無法找到BeanDefinitionParser的元素爲Spring Web服務

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [annotation-driven] 
Offending resource: ServletContext resource [/WEB-INF/spring-ws-servlet.xml] 

一些周圍挖掘後,它看起來像我極有可能版本不匹配我的模式和罐子,但我沒有看到哪裏(我爲v3.1拍攝)。

這裏是每一個罐子在我的圖書館:

M2_REPO\org\springframework\spring-aop\3.1.1.RELEASE\spring-aop-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-asm\3.1.1.RELEASE\spring-asm-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-beans\3.1.1.RELEASE\spring-beans-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-context\3.1.1.RELEASE\spring-context-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-context-support\3.1.1.RELEASE\spring-context-support-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-core\3.1.1.RELEASE\spring-core-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-expression\3.1.1.RELEASE\spring-expression-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-jdbc\3.1.1.RELEASE\spring-jdbc-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-jms\3.1.1.RELEASE\spring-jms-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-oxm\3.1.1.RELEASE\spring-oxm-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\ws\spring-oxm\1.5.10\spring-oxm-1.5.10.jar 
M2_REPO\org\springframework\ws\spring-oxm-tiger\1.5.10\spring-oxm-tiger-1.5.10.jar 
M2_REPO\org\springframework\security\spring-security-acl\3.1.1.RELEASE\spring-security-acl-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\security\spring-security-config\3.1.1.RELEASE\spring-security-config-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\security\spring-security-core\3.1.1.RELEASE\spring-security-core-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\security\spring-security-remoting\3.1.1.RELEASE\spring-security-remoting-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\security\spring-security-taglibs\3.1.1.RELEASE\spring-security-taglibs-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\security\spring-security-web\3.1.1.RELEASE\spring-security-web-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-test\3.1.1.RELEASE\spring-test-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-tx\3.1.1.RELEASE\spring-tx-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-web\3.1.1.RELEASE\spring-web-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\spring-webmvc\3.1.1.RELEASE\spring-webmvc-3.1.1.RELEASE.jar 
M2_REPO\org\springframework\ws\spring-ws-core\2.1.2.RELEASE\spring-ws-core-2.1.2.RELEASE.jar 
M2_REPO\org\springframework\ws\spring-ws-core-tiger\1.5.10\spring-ws-core-tiger-1.5.10.jar 
M2_REPO\org\springframework\ws\spring-xml\1.5.10\spring-xml-1.5.10.jar 

彈簧WS-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:sws="http://www.springframework.org/schema/web-services" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/web-services 
     http://www.springframework.org/schema/web-services/web-services-2.0.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.1.xsd"> 

    <context:component-scan base-package="my.package"/> 

    <sws:annotation-driven /> 

    <sws:dynamic-wsdl id="MyService" 
     portTypeName="MyServiceInterface" 
     locationUri="/myService/"> 
     <sws:xsd location="/WEB-INF/mySchema.xsd" /> 
    </sws:dynamic-wsdl> 

</beans> 

的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
     version="3.0"> 

    <display-name> 
     My Webservice Created By Archetype for Spring WS 
    </display-name> 

    <servlet> 
     <servlet-name>spring-ws</servlet-name> 
     <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>   
     <init-param> 
      <param-name>transformWsdlLocations</param-name> 
      <param-value>true</param-value> 
     </init-param> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>spring-ws</servlet-name> 
     <url-pattern>/*</url-pattern> 
    </servlet-mapping> 

</web-app> 

的applicationContext.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" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
       http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context-3.1.xsd"> 

    <context:component-scan base-package="my.package" /> 

    <context:annotation-config /> 

</beans> 

錯誤被扔在彈簧WS-servlet.xml中時,它讀取元素。就像我說的,我是Spring web服務的全新人物,並且認識到我的設置中可能存在一個明顯的缺陷,並且非常感謝任何幫助。謝謝!

回答

2

已解決。顯然,我的一個依賴項引入了不同版本的spring-ws,儘管它並未列在我引用的庫下。我實際上最終不需要整個依賴,所以我只是刪除它,現在我沒有得到任何錯誤。

+0

你知道它是哪個依賴嗎?我昨天已經閱讀了你的問題(在你的回答之前),我唯一能在google上提出的東西就是類似的東西。 – evandongen 2013-03-15 14:55:00

+0

那麼,我刪除的依賴是我的公司寫的,所以我不能肯定地說。我假設自從我的圖書館還有一些3.0彈簧罐,它只是spring-ws的一個老版本。 – lancex 2013-03-16 19:20:34

+0

好吧,我只是好奇( - :謝謝! – evandongen 2013-03-18 15:20:50