如何将bean声明为顶层,这是SpringAMQP的要求

I have tried creating beans in Spring which were defined in earlier versions of Spring core as beans.xml. SpringAMQP has a requirement to declare Queue, Topic Exchange, and Bindings as a top-level bean. So how should I ensure that in the bean generated would be top-level without the beans.xml.

评论
男人、繁华
男人、繁华
@Bean
public Queue queue() {
    return new Queue(...); // or QueueBuilder...
}

@Bean
public TopicExchange exch() {
    return new TopicExchange(...); // or ExchangeBuilder...
}

@Bean
public Binding binding() {
    return BindingBuilder.... // or new Binding(...).
}

These must be in a class annotated with @Confguration.

点赞
评论