2016-10-24 33 views
0

我正在使用Eclipse作爲IDE。我有一個非常基本的配置XML文件,它沒有驗證,因此阻止Eclipse運行任何東西。我錯過了什麼?春季集成Kafka配置 - Eclipse中的錯誤

這裏的驗證錯誤(我看到的問題查看): enter image description here

這裏是我的配置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/kafka http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.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/task http://www.springframework.org/schema/task/spring-task.xsd"> 

    <int:channel id="inputToKafka" /> 
    <int-kafka:outbound-channel-adapter 
     id="kafkaOutboundChannelAdapter" kafka-template="template" 
     auto-startup="false" channel="inputToKafka" topic="replicated-topic-1" 
     message-key-expression="'bar'" partition-id-expression="2"> 
    </int-kafka:outbound-channel-adapter> 

    <bean id="template" class="org.springframework.kafka.core.KafkaTemplate"> 
     <constructor-arg> 
      <bean class="org.springframework.kafka.core.DefaultKafkaProducerFactory"> 
       <constructor-arg> 
        <map> 
         <entry key="bootstrap.servers" value="192.168.33.21:9092,192.168.33.22:9092,192.168.33.23:9092" /> 
        </map> 
       </constructor-arg> 
      </bean> 
     </constructor-arg> 
    </bean> 

    <int-kafka:message-driven-channel-adapter 
     id="kafkaListener" 
     listener-container="listenerContainer" 
     auto-startup="false" 
     phase="100" 
     send-timeout="5000" 
     channel="nullChannel" 
     error-channel="errorChannel" /> 

    <bean id="listenerContainer" class="org.springframework.kafka.listener.KafkaMessageListenerContainer"> 
     <constructor-arg> 
      <bean class="org.springframework.kafka.core.DefaultKafkaConsumerFactory"> 
       <constructor-arg> 
        <map> 
         <entry key="bootstrap.servers" value="192.168.33.21:9092,192.168.33.22:9092,192.168.33.23:9092" /> 
        </map> 
       </constructor-arg> 
      </bean> 
     </constructor-arg> 
     <constructor-arg name="topics" value="replicated-topic-1" /> 
    </bean> 

</beans> 

回答

1

如果這些都只是虛假的錯誤和應用程序運行正常,它只是手段您正在解決彈簧集成核心模式here的在線版本問題。請參閱該架構頂部的重要說明,瞭解它爲什麼不是當前版本。

你可以通過使用spring-aware eclipse(例如STS或Spring IDE插件)來解決這個問題,並在項目上設置spring nature,以便從類路徑而不是因特網上正確解析模式。

或者您可以在eclipse偏好設置中轉到XML目錄,並將模式映射配置爲正確指向模式的4.3版本。

如果它確實是一個運行時問題(應用程序不會運行),那麼這意味着你在類路徑上有一個不正確的spring-integration-core版本 - 你應該使用maven或gradle來傳遞正確的版本。如果您手動構建項目類路徑,則需要彈簧集成核心版本4.3.2或更高版本(當前版本爲4.3.4)。

+0

謝謝你的迴應Gary。它似乎不是一個運行時問題。我將測試以查看它是否使用正確的版本解決,並更新我找到的內容。 – code4kix

+0

好吧,所以我嘗試了STS,所有的錯誤都消失了。沒有運行時錯誤。但是,無論我只是在計劃Eclipse中嘗試什麼,我都無法擺脫錯誤。有一件事會導致另一件事,那就是太多的衝突。還有一個原因是我應該考慮Spring Integration的Java DSL – code4kix

+1

您應該可以通過首選項中的XML目錄重新訪問它。但是爲什麼有些Spring插件可以幫助你呢?很明顯,DSL是一種更現代的配置流程的方式,但是一旦你把所有東西都對齊,一些像XML這樣的人和這種模式的東西就不那麼難。 –