spring boot 2.1.5
spring-rabbit 1.7.9
spring-amqp 1.7.9
使用旧的Spring rabbit 1.7.9将Spring boot从1.5迁移到2.1.5,在部署时导致以下异常:
java.net.URLClassLoader@763d9750
]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:507) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:404) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:389) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:248) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
... 41 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/rabbitmq/client/QueueingConsumer
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_172]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_172]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_172]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:489) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE]
... 44 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.rabbitmq.client.QueueingConsumer
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333) ~[catalina.jar:8.0.39]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167) ~[catalina.jar:8.0.39]
... 48 common frames omitted
IF I exclude amqp-client from spring-rabbit,
<exclusion>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-amqp</artifactId>
</exclusion>
<exclusion>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
</exclusion>并直接添加amqp-client依赖项以使用旧版本,
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>4.0.3</version>
</dependency>部署时抛出以下异常,amqp: com/rabbitmq/client/impl/MicrometerMetricsCollector是java.lang.NoClassDefFoundError-client 5.4.3的一部分
此外,尝试删除spring-rabbit和AMQP1.7.9版本以使用spring boot升级的默认rabbitMQ 2.1.6版本,但由于找不到setCorrelationId方法而失败
问题
是否可以使用Spring boot 2.1.5 (使用Spring 5.1.7)和spring-rabbit/amqp 1.7.9版本?
我无法更新spring-rabbit/amqp版本,因为我们使用的是自定义jars
由管理队列的团队管理,这些自定义jars是
使用1.7.9版本。因此,如果我们使用新的spring-rabbit/amqp版本,同时发送消息
找不到setCorrelationId方法导致失败
发布于 2019-12-05 06:35:36
不能;1.7.9不能与boot 2.1一起使用;2.1.x与Boot 2.1.x兼容。
当前的Boot 2.1.x版本是2.1.10,它使用Spring AMQP 2.1.12。
关联id从byte[]转换到String,并经历了一个弃用周期,以使人们更容易从1.7.x->2.0.x->2.1.x。
旧版本在1.7.x中被弃用,在2.0.x中过渡,并在2.1.x中删除,因此直接从1.7.x跳到2.1.x更加困难。
但是,即使这样,这也只是意味着将类型从byte[]更改为String。
https://stackoverflow.com/questions/59185135
复制相似问题