我以RabbitMQ開始我使用Maven創建了一個Spring Boot項目,而我正在使用Spring依賴關係來使事情發揮作用,但是,嘗試將隊列名稱外化的偵聽器並試圖使它「多隊列」,通過註釋:使用spEL的Multiqueue RabbitListener
@RabbitListener(containerFactory = "rabbitListenerContainerFactory", queues = {"#{'${my.property.containing.the.queues}'.split(',')}"})
而作爲春天的文件中所提及AMQP
開始1.5版本中,可以使用外部化屬性 的placeh隊列名稱olders和規劃環境地政司:
@Component public class MyService { @RabbitListener(queues = "#{'${property.with.comma.delimited.queue.names}'.split(',')}") public void processOrder(String data, @Header(AmqpHeaders.CONSUMER_QUEUE) String queue) { ... }
我只是得到與下面的堆棧跟蹤錯誤:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myListenerBean' defined in file [F:\workspace\MyProject\target\classes\co\com\listener\MyListenerClass.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: @RabbitListener can't resolve '[Ljava.lang.String;@4d18b73a' as either a String or a Queue
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:690)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:970)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:959)
at co.com.ExtendedAppConfig.main(ExtendedAppConfig.java:23)
Caused by: java.lang.IllegalArgumentException: @RabbitListener can't resolve '[Ljava.lang.String;@4d18b73a' as either a String or a Queue
at org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.resolveQueues(RabbitListenerAnnotationBeanPostProcessor.java:307)
at org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.processAmqpListener(RabbitListenerAnnotationBeanPostProcessor.java:242)
at org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor$1.doWith(RabbitListenerAnnotationBeanPostProcessor.java:210)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:493)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:473)
at org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.postProcessAfterInitialization(RabbitListenerAnnotationBeanPostProcessor.java:205)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1577)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
... 14 common frames omitted
我pom.xml的如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Organization-RabbitMQ</groupId>
<artifactId>Extended-Orchestrator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<dependencies>
<!-- Dependency to another project -->
<dependency>
<groupId>Organization-RabbitMQ</groupId>
<artifactId>Generic-Orchestrator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
<version>1.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.3.2.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestone</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestone</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
我我錯過了什麼?在此先感謝
你是絕對的分辯,該項目仍然有** AMQP 1.4參考.6 **這是我在該項目中早期發行的父版本管理的版本。 – Pigritia
好的。爲什麼不遵循SO規則,不接受答案來解決問題,並讓其他人在尋找類似問題時獲得收益? –