Configure a Spring JMS application with Spring Boot and annotation support

  1. Introduction

In previous posts we learned how to configure a project using Spring JMS. If you check the article introduction to messaging with Spring JMS , you will notice that it is configured using XML. This article will take advantage of the improvements introduced in Spring 4.1 version, and configure a JMS project using Java config only.

In this example we will also see how easy it can be to configure the project by using Spring Boot .

Before we get started, just note that as usual, you can take a look at the source code of the project used in the examples below.

See the example project at github .这里写链接内容

Sections:

Introduction.
The example application.
Setting up the project.
A simple example with JMS listener.
Sending a response to another queue with @SendTo.
Conclusion.
  1. The example application

The application uses a Client service to send orders to a JMS queue, where a JMS listener will be registered and handle these orders. Once received, the listener will store the order through the Store service:

We will use the Order class to create orders:

public class Order implements Serializable {
private static final long serialVersionUID = -797586847427389162L;
private final String id;
public Order(String id) {
this.id = id;
}
public String getId() {
return id;
}
}

Before moving on to the first example, we will first explore how the project structure is built.
3. Setting up the project
3.1 Configuring pom.xml

The first thing to do is to define the artifact spring-boot-starter-parent as our parent pom.


org.springframework.boot
spring-boot-starter-parent
1.2.3.RELEASE

This parent basically sets several Maven defaults and provides the dependency management for the main dependencies that we will use, like the Spring version (which is 4.1.6).

It is important to note that this parent pom defines the version of many libraries but it does not add any dependency to our project. So don’t worry about getting libraries you won’t use.

The next step is to set the basic dependencies for Spring Boot:


org.springframework.boot
spring-boot-starter

In addition to the core Spring libraries, this dependency will bring the auto configuration functionality of Spring Boot. This will allow the framework to try to automatically set up the configuration based on the dependencies you add.

Finally, we will add the Spring JMS dependency and the ActiveMQ message broker, leaving the whole pom.xml as follows:

xpadro.spring
jms-boot-javaconfig
0.0.1-SNAPSHOT
jar
JMS Spring Boot Javaconfig

org.springframework.boot
spring-boot-starter-parent
1.2.3.RELEASE



Spring Boot Configuration Annotation Processor not configured是一个警告信息,它表示在Spring Boot配置文件部署过程中,没有配置Spring Boot Configuration Annotation Processor。这并不会影响程序的运行。 @EnableConfigurationProperties注解的作用是使使用了@ConfigurationProperties注解的类生效。它可以让配置类中的属性值正确注入到对应的对象中。在使用@EnableConfigurationProperties注解时,需要将需要生效的@ConfigurationProperties类作为参数传入。 在使用@ConfigurationProperties注解时,您可以使用spring-boot-configuration-processor jar来生成配置元数据文件。这个jar包含一个Java注释处理器,当您的项目被编译时会被调用。要使用这个处理器,您需要在依赖中添加spring-boot-configuration-processor的依赖项。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Spring Boot Configuration Annotation Processor not configured 问题解决](https://blog.csdn.net/axbhealj/article/details/131351558)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [SpringBoot Configuration Annotation Processor not configured](https://blog.csdn.net/ivan416/article/details/17682015)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值