Spring集成Splunk:无法读取架构文档

时间:2016-05-27 00:09:06

标签: spring-integration splunk

运行Splunk集成弹簧适配器时出现以下错误。

  

org.xml.sax.SAXParseException; lineNumber:16; columnNumber:212;   schema_reference.4:无法读取架构文档   'http://martinfowler.com/bliki/TestPyramid.html',   因为1)找不到文件; 2)文件不可能   读; 3)文档的根元素不是。

我尝试搜索http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd,但看起来无法访问。 Spring是否已弃用Splunk的支持?

配置:

Beans.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-splunk="http://www.springframework.org/schema/integration/splunk"
        xmlns:stream="http://www.springframework.org/schema/integration/stream"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
                http://www.springframework.org/schema/integration/splunk http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
                http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.4.RELEASE.xsd">
        <import resource="SplunkInboundChannelAdapterCommon-context.xml"/>

        <int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
                auto-startup="true" search="sourcetype=SplunkRabbitMQ_messaging | spath input=msg_body | where '3' > 0" splunk-server-ref="splunkServer" channel="inputFromSplunk" mode="realtime" initEarliestTime="-1d">
                <int:poller fixed-rate="5" time-unit="SECONDS"/>
        </int-splunk:inbound-channel-adapter>

</beans>

SplunkCommon-context.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-splunk="http://www.springframework.org/schema/integration/splunk"
         xmlns:stream="http://www.springframework.org/schema/integration/stream"
         xmlns:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="http://www.springframework.org/schema/integration/stream
 http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
                 http://www.springframework.org/schema/integration/splunk
 http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
                 http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
                 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.4.RELEASE.xsd">

         <context:component-scan base-package="org.springframework.integration.splunk"></context:component-scan>
         <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"/>

         <int-splunk:server id="splunkServer" host="xxx.xx.xx.xxx" port="8089" userName="admin" password="ferggegtg" owner="admin"/>

 </beans>

SplunkInboundChannelAdapterCommon-context.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-splunk="http://www.springframework.org/schema/integration/splunk"
        xmlns:stream="http://www.springframework.org/schema/integration/stream"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
                http://www.springframework.org/schema/integration/splunk http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
                http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.4.RELEASE.xsd">

        <import resource="SplunkCommon-context.xml"/>
        <context:component-scan base-package="org.springframework.integration.samples.splunk"></context:component-scan>
        <int:channel id="inputFromSplunk">
        </int:channel>
        <int:service-activator input-channel="inputFromSplunk" ref="splunkDataHandler"></int:service-activator>
        <!-- <stream:stdout-channel-adapter id="stdout" channel="inputFromSplunk" append-newline="true"/> -->


</beans>

1 个答案:

答案 0 :(得分:1)

模式不在线,spring从jar中的META-INF/spring-schemas中的jar类中的类路径解析它 - 如果这是运行时错误,则表明您在类路径上没有jar。如果此错误仅在IDE中(而不是在运行时),您使用的是一个不具有弹簧感知的错误 - 您可以忽略IDE中的错误,使用可识别Spring的IDE,或使用IDE功能手动添加模式映射。