IneligibleMethodException:找到多个参数类型候选 - Spring 集成
IneligibleMethodException: Found more than one parameter type candidate - Spring Integration
我正在使用
<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(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)
我错过了什么?
请让自己更熟悉 Spring 中的 Messaging Gateway 集成:https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#gateway.
简而言之:网关是一个在其方法调用上发送消息的接口。
Message
是这样的:
public interface Message<T> {
/**
* Return the message payload.
*/
T getPayload();
/**
* Return message headers for the message (never {@code null} but may be empty).
*/
MessageHeaders getHeaders();
}
由于您没有 Message
类型作为您的参数之一,框架不知道将它们中的哪一个映射到它要创建的消息的有效负载。
请确保使用 @Payload
将什么参数传递给有效负载。哪一个将使用 @Header
注释添加到 headers。所有这些信息都出现在我 link 开头的文档中。
我正在使用
<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(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)
我错过了什么?
请让自己更熟悉 Spring 中的 Messaging Gateway 集成:https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#gateway.
简而言之:网关是一个在其方法调用上发送消息的接口。
Message
是这样的:
public interface Message<T> {
/**
* Return the message payload.
*/
T getPayload();
/**
* Return message headers for the message (never {@code null} but may be empty).
*/
MessageHeaders getHeaders();
}
由于您没有 Message
类型作为您的参数之一,框架不知道将它们中的哪一个映射到它要创建的消息的有效负载。
请确保使用 @Payload
将什么参数传递给有效负载。哪一个将使用 @Header
注释添加到 headers。所有这些信息都出现在我 link 开头的文档中。