Skip to content

ListenerContainerConfiguration should not depend on concrete class StandardEnvironment #477

@fishautumn

Description

@fishautumn

Interface ConfigurableEnvironment should be enough for bellow code:

code link:

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: {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions