spring集成activemq
1、maven引入spring-jms和activemq-client(注意版本兼容的问题)
<properties>
<spring.version>4.3.4.RELEASE</spring.version>
<activemq.version>5.14.0</activemq.version>
</properties>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>${activemq.version}</version>
</dependency>
小插曲:一开始我引入activemq-all,导致启动报错
java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/Class;)Ljava/lang/annotation/Annotation;] with root cause
这是因为跟spring-core版本冲突了,其实没必要引入activemq-all,只要activemq-cilent就够了
最终maven会下载5个jar包
spring-jms-4.3.4.RELEASE-sources.jar
activemq-client-5.14.0.jar
geronimo-jms_1.1_spec-1.1.1.jar
hawtbuf-1.11.jar
geronimo-j2ee-management_1.1._spec-1.0.1.jar
2、配置spring-avtivemq.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance