xml – maven spring – 找不到元素’beans’的声明

前端之家收集整理的这篇文章主要介绍了xml – maven spring – 找不到元素’beans’的声明前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个使用maven构建的 spring项目(打包为jar)(依赖项被复制到一个单独的目录并添加到classpath中)

我想以java -jar的形式运行它

问题是当我运行它时,我得到:

导致:org.xml.sax.SAXParseException:cvc-elt.1:找不到声明
元素“豆”.

这是因为spring.schemas和spring.handlers位于几个jar,即:spring-beans等

有没有办法解决它,假设我不想使用阴影插件来解压缩所有依赖项并连接spring.schemas和spring.handlers的内容

我还要避免在我的项目中保存xsd文件,并将schemaLocation更改为指向我的位置.

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:camel="http://camel.apache.org/schema/spring"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

    <camel:camelContext>
        <camel:routeBuilder ref="fakeRouteBuilder"/>
    </camel:camelContext>

    <bean id="fakeRouteBuilder" class="<className>" />


</beans>@H_404_15@
我知道2种情况,你可以有这个问题

>如果您没有互联网连接(例如在代理之后).在这种情况下,请下载XSD,将其复制到XML旁边,并将模式位置更改为xsi:schemaLocation =“http://www.springframework.org/schema/beans spring-beans-2.5.xsd …”>如果您有互联网连接/仍然有问题,那是因为您使用不同版本的Spring for XSD和jar.

原文链接:https://www.f2er.com/xml/292879.html

猜你在找的XML相关文章