> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/32.-messaging/32.3-apache-kafka-support/32.3.1-sending-a-message.md).

# 32.3.1 发送消息

Spring的`KafkaTemplate`会自动配置。你可以直接在你自己的bean里面自动装配它。如下所示：

```java
@Component
public class MyBean {

    private final KafkaTemplate kafkaTemplate;

    @Autowired
    public MyBean(KafkaTemplate kafkaTemplate) {
        this.kafkaTemplate = kafkaTemplate;
    }

    // ...

}
```

**注** 如果定义了`RecordMessageConverter` bean，它会自动关联到自动配置好的`KafkaTemplate`。
