Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListenerContainerConfiguration should not depend on concrete class StandardEnvironment #477

Closed
fishautumn opened this issue Aug 4, 2022 · 2 comments · Fixed by #478
Closed
Labels
enhancement New feature or request

Comments

@fishautumn
Copy link
Contributor

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: {}
@panzhi33
Copy link
Contributor

Can inherit StandardEnvironment to customize, this can meet your business. StandardEnvironment also implements ConfigurableEnvironment

@fishautumn
Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants