我正在使用
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-http</artifactId>
</dependency>
我有一个控制器,在那里我收到一个路径变量和请求体
@PatchMapping("/applications/{applicationId}/disclosure")
public void piSubmission(@PathVariable(value = "applicationId") String applicationId,
@RequestBody DisclosureInfo disclosureInfo) {
disclosureGateway.process(applicationId, disclosureInfo);
}
我使用一个网关初始化这个进程,所以我将2个值传递给它
@MessagingGateway
public interface DisclosureGateway {
@Gateway(requestChannel = "disclosure")
void process(String applicationId, DisclosureInfo disclosureInfo);
}
但我犯了以下错误
Caused by: java.lang.IllegalArgumentException: org.springframework.integration.handler.support.MessagingMethodInvokerHelper$IneligibleMethodException: Found more than one parameter type candidate: [java.lang.String] and [v3.b.engine.domain.kernel.DisclosureInfo]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.createHandlerMethod(MessagingMethodInvokerHelper.java:396)
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:255)
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:206)
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:210)
at org.springframework.integration.handler.MethodInvokingMessageProcessor.<init>(MethodInvokingMessageProcessor.java:50)
at org.springframework.integration.transformer.MethodInvokingTransformer.<init>(MethodInvokingTransformer.java:38)
at org.springframework.integration.config.annotation.TransformerAnnotationPostProcessor.createHandler(TransformerAnnotationPostProcessor.java:71)
at org.springframework.integration.config.annotation.AbstractMethodAnnotationPostProcessor.postProcess(AbstractMethodAnnotationPostProcessor.java:158)
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.postProcessMethodAndRegisterEndpointIfAny(MessagingAnnotationPostProcessor.java:230)
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.lambda$processAnnotationTypeOnMethod$1(MessagingAnnotationPostProcessor.java:220)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.afterSingletonsInstantiated(MessagingAnnotationPostProcessor.java:141)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:963)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:923)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:123)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
... 67 more
Caused by: org.springframework.integration.handler.support.MessagingMethodInvokerHelper$IneligibleMethodException: Found more than one parameter type candidate: [java.lang.String] and [v3.b.engine.domain.kernel.DisclosureInfo]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper$HandlerMethod.setExclusiveTargetParameterType(MessagingMethodInvokerHelper.java:1334)
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper$HandlerMethod.processMethodParameterForExpression(MessagingMethodInvokerHelper.java:1199)
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper$HandlerMethod.generateExpression(MessagingMethodInvokerHelper.java:1152)
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper$HandlerMethod.<init>(MessagingMethodInvokerHelper.java:1091)
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.createHandlerMethod(MessagingMethodInvokerHelper.java:391)
我错过了什么?
1条答案
按热度按时间3vpjnl9f1#
请让自己更熟悉什么是spring integration中的消息网关:https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#gateway.
换句话说:网关是一个接口,用于在方法调用时发送消息。
这个
Message
是这样的:既然你没有
Message
键入作为参数之一,框架不知道要将其中的哪一个Map到要创建的消息的有效负载。请确定使用
@Payload
在上面。以及使用@Header
注解。所有这些信息都存在于我在开头链接的文档中。