ListenerContainerConfiguration should not depend on concrete class StandardEnvironment
Interface ConfigurableEnvironment should be enough for bellow code:
code link: https://github.com/apache/rocketmq-spring/blob/21097621e092a618709f8220ee2ccd0acbaa3af0/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/autoconfigure/ListenerContainerConfiguration.java#L55
My application has a customized ConfigurableEnvironment implementation, but it cannot startup correctly.
Below is a demo code fragment:
@SpringBootApplication
public class App {
@Resource
private RocketMQTemplate rocketMQTemplate;
public static void main(String[] args) {
SpringApplication app = new SpringApplication(App.class);
app.setEnvironment(new MyEnv()); // comment out this line fixies the problem
app.run(args);
}
static class MyEnv extends AbstractEnvironment {
}
}
it reports bellow error on startup:
Error creating bean with name 'org.apache.rocketmq.spring.autoconfigure.ListenerContainerConfiguration':
Unsatisfied dependency expressed through constructor parameter 1;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'org.springframework.core.env.StandardEnvironment' available:
expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations: {}
Can inherit StandardEnvironment to customize, this can meet your business. StandardEnvironment also implements ConfigurableEnvironment
Can inherit StandardEnvironment to customize, this can meet your business. StandardEnvironment also implements ConfigurableEnvironment
Yes, it works.
However, I think rocketmq-spring only depends on interface ConfigurableEnvironment, so there is no reason to depend on StandardEnvironment, right?