Sou*_*nta 3 java xml spring xsd drools
org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'drools:grid-node'.
Run Code Online (Sandbox Code Playgroud)
当我向 spring xml 添加网格节点和 ksession 时,出现此错误。我做了一些搜索,看起来像是一个类路径问题。我在这里缺少什么依赖项?
<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"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://drools.org/schema/drools-spring org/drools/container/spring
http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd">
<drools:grid-node id="node1"/>
<drools:ksession id="ksession1" type="stateful" kbase="kbase1" node="node1" />
Run Code Online (Sandbox Code Playgroud)
我的 pom.xml 具有 Drools 的以下内容。
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-camel</artifactId>
<version>${drools.version}</version>
<exclusions>
<!-- This ensures that we use the latest version of Spring jars and not
the one that comes with drools.version. -->
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
</exclusion>
<exclusion>
<artifactId>camel-xstream</artifactId>
<groupId>org.apache.camel</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-spring</artifactId>
<version>${drools.version}</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
发出此错误是因为无法找到 Drools XSD。在Drools 用户列表中的此评论中,指出 XSD 不是公开可用的,并且xsi:schemaLocationXML 中的属性将该 XSD 映射到http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd, which doesn't resolve to the proper XSD.
Spring 应该自动处理给定xmlns:drools="http://drools.org/schema/drools-spring"属性的 XSD 解析。Drools JAR 之一应该包含一个META-INF/spring.handlers定义命名空间的 XSD 映射的文件drools。大致如下:
http://drools.org/schema/drools-spring=some.classpath.visible.package.xsdfile.xsd
Run Code Online (Sandbox Code Playgroud)
它应该自动处理 Drools JAR 中包含的 XSD 文件。
尝试删除最后两行xsi:schemaLocation attribute in order to let Spring automatically resolve the XSD.
一些相关链接:
当然,您也可以从 JAR 文件中提取该 XSD,将其放置在类路径中可访问的目录中,并使用类路径相对 URLxsi:schemaLocation.
顺便说一句,这可能是复制粘贴错误,但是您的<beans> element is missing its closing tag.
编辑:看起来 Drools 没有提供spring.handlers正确的(至少截至 2010 年 12 月,请参阅Drools + Spring without internet)。您可能需要深入 JAR 来获取 XSD 并直接在xsi:schemaLocation.
| 归档时间: |
|
| 查看次数: |
11487 次 |
| 最近记录: |