2016-04-06 15 views
0

私は春 - 雲の流れを研究し、いくつかの問題に直面しました。spring-cloud-streamオブジェクト 'spring.cloud.stream' on field 'bindings [入力]'

@EnableBinding(Source.class) 
public class SendSource { 

    private String format = "yyyy-MM-dd HH:mm:ss"; 

    @Bean 
    @InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "1")) 
    public MessageSource<String> send(){ 

     return()->new GenericMessage<>(new SimpleDateFormat(this.format).format(new Date())); 

    } 

とシンク:

@EnableBinding(Sink.class) 
public class SinkMoudle { 
    @ServiceActivator(inputChannel=Sink.INPUT) 
    public void loggerSink(Object payload) { 
     System.out.println("Received: " + payload); 
    } 
} 

アプリケーションを起動する、のRedis-CLI:

1459914852.842206 [0 127.0.0.1:49630] "PING" 
1459914857.627916 [0 127.0.0.1:49630] "ZRANGEBYSCORE" "groups.testtock" "1.0" "1.7976931348623157E308" 
1459914862.633039 [0 127.0.0.1:49630] "ZRANGEBYSCORE" "groups.testtock" "1.0" "1.7976931348623157E308" 

問題がある:

1:redis- cliのエクスポートは「2016-04-06 12:07:19」のようにする必要がありますが、 ない

2:コンソールエラー:

2016-04-06 12:16:02.505 ERROR 74368 --- [   main] o.s.b.b.PropertiesConfigurationFactory : Properties configuration failed validation 
    2016-04-06 12:16:02.505 ERROR 74368 --- [   main] o.s.b.b.PropertiesConfigurationFactory : Field error in object 'spring.cloud.stream' on field 'bindings[input]': rejected value [testtock]; codes [typeMismatch.spring.cloud.stream.bindings[input],typeMismatch.spring.cloud.stream.bindings,typeMismatch.bindings[input],typeMismatch.bindings,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.stream.bindings[input],bindings[input]]; arguments []; default message [bindings[input]]]; default message [Failed to convert property value of type [java.lang.String] to required type [org.springframework.cloud.stream.config.BindingProperties] for property 'bindings[input]'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.cloud.stream.config.BindingProperties] for property 'bindings[input]': no matching editors or conversion strategy found] 
    2016-04-06 12:16:02.562 INFO 74368 --- [   main] o.s.s.c.ThreadPoolTaskScheduler   : Initializing ExecutorService 'taskScheduler' 
    2016-04-06 12:16:02.604 ERROR 74368 --- [   main] o.s.b.b.PropertiesConfigurationFactory : Properties configuration failed validation 
    2016-04-06 12:16:02.604 ERROR 74368 --- [   main] o.s.b.b.PropertiesConfigurationFactory : Field error in object 'spring.cloud.stream' on field 'bindings[input]': rejected value [testtock]; codes [typeMismatch.spring.cloud.stream.bindings[input],typeMismatch.spring.cloud.stream.bindings,typeMismatch.bindings[input],typeMismatch.bindings,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.stream.bindings[input],bindings[input]]; arguments []; default message [bindings[input]]]; default message [Failed to convert property value of type [java.lang.String] to required type [org.springframework.cloud.stream.config.BindingProperties] for property 'bindings[input]'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.cloud.stream.config.BindingProperties] for property 'bindings[input]': no matching editors or conversion strategy found] 
    2016-04-06 12:16:02.604 WARN 74368 --- [   main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bindingService' defined in class path resource [org/springframework/cloud/stream/config/ChannelBindingServiceConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.cloud.stream.config.ChannelBindingServiceProperties]: Error creating bean with name 'spring.cloud.stream.CONFIGURATION_PROPERTIES': Could not bind properties to ChannelBindingServiceProperties (prefix=spring.cloud.stream, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 1 errors 
    Field error in object 'spring.cloud.stream' on field 'bindings[input]': rejected value [testtock]; codes [typeMismatch.spring.cloud.stream.bindings[input],typeMismatch.spring.cloud.stream.bindings,typeMismatch.bindings[input],typeMismatch.bindings,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.stream.bindings[input],bindings[input]]; arguments []; default message [bindings[input]]]; default message [Failed to convert property value of type [java.lang.String] to required type [org.springframework.cloud.stream.config.BindingProperties] for property 'bindings[input]'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.cloud.stream.config.BindingProperties] for property 'bindings[input]': no matching editors or conversion strategy found]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.cloud.stream.CONFIGURATION_PROPERTIES': Could not bind properties to ChannelBindingServiceProperties (prefix=spring.cloud.stream, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 1 errors 
    Field error in object 'spring.cloud.stream' on field 'bindings[input]': rejected value [testtock]; codes [typeMismatch.spring.cloud.stream.bindings[input],typeMismatch.spring.cloud.stream.bindings,typeMismatch.bindings[input],typeMismatch.bindings,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.stream.bindings[input],bindings[input]]; arguments []; default message [bindings[input]]]; default message [Failed to convert property value of type [java.lang.String] to required type [org.springframework.cloud.stream.config.BindingProperties] for property 'bindings[input]'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.cloud.stream.config.BindingProperties] for property 'bindings[input]': no matching editors or conversion strategy found] 
    2016-04-06 12:16:02.605 INFO 74368 --- [   main] o.s.s.c.ThreadPoolTaskScheduler   : Shutting down ExecutorService 'taskScheduler' 
    2016-04-06 12:16:02.611 INFO 74368 --- [   main] o.apache.catalina.core.StandardService : Stopping service Tomcat 
    2016-04-06 12:16:02.679 ERROR 74368 --- [   main] o.s.boot.SpringApplication    : Application startup failed 

答えて

1

あなたが結合特性を設定するために、環境変数を使用しようとしているように見えます。そうであれば、あなたは問題に対処します。here thereで示唆されているように、SPRING_APPLICATION_JSONを使用してenv変数を渡すことができます。

+0

おそらく、私はenv変数を渡しませんでした。私はすべてのコードを入れて詳細をhttps://github.com/keryhu/spring-cloud-stream-1に入れます。 –

+0

OK、あなたはそのプロパティのために 'spring.cloud.stream.bindings.input.destination'プロパティが必要ですシンク。デフォルトチャネルプロパティはサポートされていません。これは間違っています:https://github.com/keryhu/spring-cloud-stream-1/blob/master/spring-stream/sink-service/src/main/resources/application.yml#L8 –

関連する問題