在以下链接中 http://docs.spring.io/spring-amqp/reference/html/quick-tour.html
它在 XML 中定义了一个 bean,例如
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory"/>
然后在调用代码中,使用了
AmqpTemplate template = context.getBean(AmqpTemplate.class);
为什么使用
context.getBean(AmqpTemplate.class);
而不是
context.getBean("amqpTemplate");
getBean(AmqpTemplate.class) 是什么意思?我找不到它由xml定义的。
最佳答案
关于java - 从 spring 获取 bean 时使用哪个 context.getBean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26737436/