微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java-为什么在Tomcat加载和读取bean.xml时不能正确加载Spring AOP XML模式

我试图在Eclipse中使用Spring’s Schema Based AOP Support,并且尝试在Tomcat中加载配置时遇到错误.

Eclipse中没有错误,并且自动完成功能对于aop命名空间正常工作,但是当我尝试将项目加载到eclipse中时,出现以下错误

09:17:59,515 WARN XmlBeanDeFinitionReader:47 – Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document ‘http://www.springframework.org/schema/aop/spring-aop-2.5.xsd’, because 1) Could not find the document; 2) the document Could not be read; 3) the root element of the document is not .

其次是:

SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.xml.XmlBeanDeFinitionStoreException: Line 39 in XML document from /WEB-INF/beans.xml is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘aop:config’.

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘aop:config’.

基于此,当Tomcat解析bean.xml文件时,似乎未读取架构,从而导致< aop:config>.元素未被识别.

我的beans.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:jaxws="http://cxf.apache.org/jaxws"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
        http://cxf.apache.org/jaxws 
        http://cxf.apache.org/schemas/jaxws.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

    <!--import resource="classpath:meta-inf/cxf/cxf.xml" /-->
    <!--import resource="classpath:meta-inf/cxf/cxf-extension-soap.xml" /-->
    <!--import resource="classpath:meta-inf/cxf/cxf-servlet.xml" /-->

    <!-- NOTE: endpointName attribute maps to wsdl:port@name & should 
                be the same as the portName attribute
                in the @WebService annotation on the IWebServiceImpl class -->
    <!-- NOTE: serviceName attribute maps to wsdl:service@name & should be 
                the same as the serviceName attribute in the @WebService 
                 annotation on the ASDIWebServiceImpl class -->
    <!-- NOTE: address attribute is the actual URL of the web service 
                (relative to web app location) -->
    <jaxws:endpoint
            xmlns:tns="http://iwebservices.ourdomain/"

            id="iwebservices"
            implementor="ourdomain.iwebservices.IWebServiceImpl"
            endpointName="tns:IWebServiceImplPort"
            serviceName="tns:IWebService"
            address="/I"
            wsdlLocation="wsdl/I.wsdl">
            <!-- To have CXF auto-generate WSDL on the fly, comment out the above wsdl 
            attribute -->

            <jaxws:features>
                    <bean class="org.apache.cxf.feature.LoggingFeature" />
            </jaxws:features>
    </jaxws:endpoint>


    <aop:config>
    <aop:aspect id="myAspect" ref="aBean">

    </aop:aspect>
    </aop:config>


</beans>

< aop:config>我的bean.xml文件中的元素是从Spring website复制粘贴的,以尝试删除任何可能的错误

任何人都可以阐明为什么会发生此错误以及如何解决错误吗?

解决方法:

检查您的Web应用程序的WEB-INF / lib文件夹中是否有Spring AOP jar(spring-aop.jar).

jar包含指定的XSD.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。