From 00378d2979f41ad7d0c050abb29f7976336ecc00 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Fri, 27 Feb 2015 20:51:42 +0800 Subject: [PATCH] Update 30.1.4. Sending a message.md --- .../30.1.4. Sending a message.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/IV. Spring Boot features/30.1.4. Sending a message.md b/IV. Spring Boot features/30.1.4. Sending a message.md index e69de29..56b883a 100644 --- a/IV. Spring Boot features/30.1.4. Sending a message.md +++ b/IV. Spring Boot features/30.1.4. Sending a message.md @@ -0,0 +1,19 @@ +### 30.1.4. 发送消息 + +Spring的JmsTemplate会被自动配置,你可以将它直接注入到你自己的beans中: +```java +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jms.core.JmsTemplate; +import org.springframework.stereotype.Component; +@Component +public class MyBean { +private final JmsTemplate jmsTemplate; +@Autowired +public MyBean(JmsTemplate jmsTemplate) { +this.jmsTemplate = jmsTemplate; +} +// ... +} +``` + +**注**:[JmsMessagingTemplate](http://docs.spring.io/spring/docs/4.1.4.RELEASE/javadoc-api/org/springframework/jms/core/JmsMessagingTemplate.html)(Spring4.1新增的)也可以使用相同的方式注入