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>
我知道2种情况,你可以有这个问题

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

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念