小编JJT*_*JJT的帖子

maven spring - 找不到元素'beans'的声明

我有一个使用maven构建的spring项目(打包为jar)(依赖项被复制到一个单独的目录并添加到classpath)

我想以java -jar运行它

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

引起:org.xml.sax.SAXParseException:cvc-elt.1:找不到元素'beans'的声明.

之所以会发生这种情况,是因为spring.schemas和spring.handlers位于几个罐子中,即:spring-beans等.

有没有办法解决它,假设我不想使用shade插件解压所有依赖项并连接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>
Run Code Online (Sandbox Code Playgroud)

xml schema spring maven-2 maven

13
推荐指数
4
解决办法
2万
查看次数

标签 统计

maven ×1

maven-2 ×1

schema ×1

spring ×1

xml ×1