Spring-integration-kafka - 我正在创建Spring-integration-kakfa应用程序,但在启动时它给了我错误,请在下面找到错误堆栈 -
Caused by: org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 110; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'int-kafka:inbound-channel-adapter'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1911)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)
我可以找到几个基于Java的配置示例,但需要基于XML的Kafka生产者和消费者配置。有人可以帮我这个吗?
kafka-inbound-channel.xml -
<?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:int="http://www.springframework.org/schema/integration"
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/kafka/
http://www.springframework.org/schema/integration/kafka/spring-integration-kafka-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<int:channel id="inputFromKafka">
<int:dispatcher task-executor="kafkaMessageExecutor" />
</int:channel>
<task:executor id="kafkaMessageExecutor" pool-size="0-10"
keep-alive="120" queue-capacity="500" />
<int-kafka:inbound-channel-adapter kafka-consumer-context-ref="consumerContext" channel="inputFromKafka">
<int:poller fixed-delay="10" />
</int-kafka:inbound-channel-adapter>
<int-kafka:consumer-context id="consumerContext"
consumer-timeout="4000" zookeeper-connect="zookeeperConnect">
<int-kafka:consumer-configurations>
<int-kafka:consumer-configuration
group-id="default" value-decoder="deccoder" key-decoder="deccoder"
max-messages="5000">
<int-kafka:topic id="FppTopic1" streams="4" />
<int-kafka:topic id="FppTopic2" streams="4" />
</int-kafka:consumer-configuration>
</int-kafka:consumer-configurations>
</int-kafka:consumer-context>
<int-kafka:zookeeper-connect id="zookeeperConnect"
zk-connect="sd-dc1b-b0ce:2181"
zk-connection-timeout="6000"
zk-session-timeout="6000"
zk-sync-time="2000"/>
<bean id="deccoder" class="org.springframework.integration.kafka.serializer.common.StringDecoder" />
</beans>
其他配置是在调度程序servlet中将普通的Spring MVC应用程序配置导入资源为“kafka-inbound-channle.xml”但在import语句之后它会出现此错误
答案 0 :(得分:0)
确实应该显示您的XML配置。否则,喝咖啡真的很难帮助。
您可以在项目的测试中找到一些示例:https://github.com/spring-projects/spring-integration-kafka/tree/master/src/test/java/org/springframework/integration/kafka/config/xml
另一方面,有时这是IDE中的错误。考虑使用符合Spring的版本。例如IntelliJ IDEA或STS。