使用的spring版本是5.0.4.RELEASE,activemq-core版本5.7.0。這個版本的Spring需要使用JMS 2.0版本,但spring-jms的依賴沒有自動導入JMS 2.0,而activemq-core會導入JMS 1.1的依賴,這就導致出現版本問題,
可以添加一下依賴解決,JMS 2.0 依賴如下
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
</dependency>
爲了防止衝突,可以從activemq-core中去除JMS 1.1,pom 如下所示
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.7.0</version>
<exclusions>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
</exclusion>
</exclusions>
</dependency>