无法为 Spring Web 服务的元素找到 BeanDefinitionParser [英] Cannot locate BeanDefinitionParser for element for Spring web services

查看:16
本文介绍了无法为 Spring Web 服务的元素找到 BeanDefinitionParser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Spring Web 服务的新手,我不断收到此错误:

I am brand new to Spring web services and I keep getting this error:

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]

经过一番挖掘,看起来我的架构和 jar 之间的版本很可能不匹配,但我看不出在哪里(我正在为 v3.1 拍摄).

After some digging around, it looks like I most likely have a version mismatch between my schemas and jars but I do not see where (I'm shooting for v3.1).

这是我库中的每个 Spring jar:

Here is every Spring jar in my library:

M2_REPOorgspringframeworkspring-aop3.1.1.RELEASEspring-aop-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-asm3.1.1.RELEASEspring-asm-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-beans3.1.1.RELEASEspring-beans-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-context3.1.1.RELEASEspring-context-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-context-support3.1.1.RELEASEspring-context-support-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-core3.1.1.RELEASEspring-core-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-expression3.1.1.RELEASEspring-expression-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-jdbc3.1.1.RELEASEspring-jdbc-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-jms3.1.1.RELEASEspring-jms-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-oxm3.1.1.RELEASEspring-oxm-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkwsspring-oxm1.5.10spring-oxm-1.5.10.jar
M2_REPOorgspringframeworkwsspring-oxm-tiger1.5.10spring-oxm-tiger-1.5.10.jar
M2_REPOorgspringframeworksecurityspring-security-acl3.1.1.RELEASEspring-security-acl-3.1.1.RELEASE.jar
M2_REPOorgspringframeworksecurityspring-security-config3.1.1.RELEASEspring-security-config-3.1.1.RELEASE.jar
M2_REPOorgspringframeworksecurityspring-security-core3.1.1.RELEASEspring-security-core-3.1.1.RELEASE.jar
M2_REPOorgspringframeworksecurityspring-security-remoting3.1.1.RELEASEspring-security-remoting-3.1.1.RELEASE.jar
M2_REPOorgspringframeworksecurityspring-security-taglibs3.1.1.RELEASEspring-security-taglibs-3.1.1.RELEASE.jar
M2_REPOorgspringframeworksecurityspring-security-web3.1.1.RELEASEspring-security-web-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-test3.1.1.RELEASEspring-test-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-tx3.1.1.RELEASEspring-tx-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-web3.1.1.RELEASEspring-web-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkspring-webmvc3.1.1.RELEASEspring-webmvc-3.1.1.RELEASE.jar
M2_REPOorgspringframeworkwsspring-ws-core2.1.2.RELEASEspring-ws-core-2.1.2.RELEASE.jar
M2_REPOorgspringframeworkwsspring-ws-core-tiger1.5.10spring-ws-core-tiger-1.5.10.jar
M2_REPOorgspringframeworkwsspring-xml1.5.10spring-xml-1.5.10.jar

spring-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我什至不确定我是否需要这个......

applicationContext.xml I'm not sure that I even need this...

<?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>

当 spring-ws-servlet.xml 读取一个元素时,就会抛出错误.就像我说的,我是 Spring Web 服务的新手,我意识到我的设置中可能存在明显的缺陷,非常感谢任何帮助.谢谢!

The error is being thrown in spring-ws-servlet.xml whenever it reads a element. Like I said, I'm brand new to Spring web services and recognize that there is probably an obvious flaw in my setup and would greatly appreciate any help. Thanks!

推荐答案

解决了.显然,我的一个依赖项是引入了不同版本的 spring-ws,即使它没有列在我引用的库下.实际上我最终不需要整个依赖项,所以我只是删除了它,现在我没有收到任何错误.

Solved. Apparently one of my dependencies was bringing in a different version of spring-ws even though it wasn't listed under my referenced libraries. I actually ended up not needing the whole dependency so I simply removed it and now I'm not getting any errors.

这篇关于无法为 Spring Web 服务的元素找到 BeanDefinitionParser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆