spring-boot - Failed to start bean 'inputBindingLifecycle' - A consumer group is required for a partitioned subscription
问题描述
I'm having a problem on test a Spring Cloud Stream 3.1.3 application.
I've this application.yml
:
...
spring:
cloud:
stream:
bindings:
input-in-0:
destination: {DESTINATION}
contentType: application/json
group: {GROUP}
...
Obviously I wrote a Consumer method annotated with @Bean
that I named input();
I replaced, for tests, this dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<scope>test</scope>
</dependency>
with this
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<type>test-jar</type>
<scope>test</scope>
<classifier>test-binder</classifier>
</dependency>
And finally this is the test class:
@SpringBootTest
class ApplicationTest {
@Autowired
private Application application;
@Test
void shouldStartTheApplication(){
Assertions.assertNotNull(application);
}
}
Now, when I run this test with new test-binder
dependency, test fails and logs this exception:
Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'inputBindingLifecycle'; nested exception is java.lang.IllegalArgumentException: A consumer group is required for a partitioned subscription
Instead, if I don't replace spring-cloud-stream-test-support
, test passes.
Why, according dependencies I use, is test result different? Thank you
解决方案
推荐阅读
- amazon-web-services - Cloudformation AWS:在安全组之间进行选择
- asciidoctor - Asciidoctor - 在一张大桌子上溢出
- java - Java converting to a char from a string into the correct byte 0-255
- c# - Query issue of datetime datatype to date
- python-3.x - Why Autoreload throw error on class import?
- java - Accessing field in Java based on condition
- flutter - 如何在库比蒂诺日期选择器字段中显示初始日期
- javascript - Distributable/Distributed Web App with VueJS
- pandas - pandas-like resampling with week frequency in DolphinDB
- json - 如何访问 json / ruby 中的键、值