为什么Tomcat加载时没有正确加载Spring AOP XML模式?读取beans.xml [英] Why isn't the Spring AOP XML schema properly loaded when Tomcat loads & reads beans.xml

查看:125
本文介绍了为什么Tomcat加载时没有正确加载Spring AOP XML模式?读取beans.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Spring的架构在Eclipse中基于AOP支持并且在尝试在Tomcat中加载配置时遇到错误。

I'm trying to use Spring's Schema Based AOP Support in Eclipse and am getting errors when trying to load the configuration in Tomcat.

Eclipse中没有错误,自动完成工作正常aop命名空间,但当我尝试将项目加载到eclipse时,我收到此错误:

There are no errors in Eclipse and auto-complete works correctly for the aop namespace, however when I try to load the project into eclipse I get this error:


09:17:59,515 WARN XmlBeanDefinitionReader:47 - 忽略XML验证警告
org.xml.sax.SAXParseException:schema_reference.4:无法读取模式文档'http://www.springframework.org/schema/aop/spring-aop-2.5.xsd',因为1)找不到文件; 2)文件无法阅读; 3)文件的根元素不是。

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:来自/WEB-INF/beans.xml的XML文档中的第39行无效;嵌套异常是org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'aop:config'的声明。

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'.

引起:org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'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解析beans.xml文件时,似乎没有读取模式,导致 < aop:config> 元素无法被识别。

Based on this, it seems the schema is not being read when Tomcat parses the beans.xml file, leading to the <aop:config> element not being recognised.

我的beans.xml文件如下:

My beans.xml file is as follows:

<?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> 元素在我的 beans.xml 文件中,从 Spring网站尝试删除任何可能的错误来源

The <aop:config> element in my beans.xml file is copy-pasted from the Spring website to try and remove any possible source of error

任何人都可以流下关于为什么会出现这种错误以及我可以采取哪些措施来解决这个问题?

推荐答案

检查你有没有您的webapp的WEB-INF / lib文件夹中的Spring AOP jar(spring-aop.jar)。

Check that you have the Spring AOP jar (spring-aop.jar) in the WEB-INF/lib folder of your webapp.

该jar包含指定的XSD。

That jar contais the specified XSD.

这篇关于为什么Tomcat加载时没有正确加载Spring AOP XML模式?读取beans.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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