Ich hatte intally findByNameAndId (String name) in meinem GetAccountsDAO. Später änderte sich die Anforderung und ich musste ID (Long) hinzufügen.java.lang.IllegalArgumentException: Es wurden mehr als ein Parametertypkandidat gefunden: [java.lang.String] und [java.lang.Long]
Nach dem Hinzufügen der Implementierung, als ich es testen wollte. Es begann zu versagen.
/**
* The interface that is used to get account
*/
public interface GetAccountsDAO {
@SuppressWarnings("unchecked")
public List<Account> findByNameAndId(String name, Long id);
}
Die Fehlerprotokolle sind:
java.lang.IllegalArgumentException: Found more than one parameter type candidate: [java.lang.String] and [java.lang.Long]
at org.springframework.util.Assert.isNull(Assert.java:89)
at org.springframework.integration.util.MessagingMethodInvokerHelper$HandlerMethod.setExclusiveTargetParameterType(MessagingMethodInvokerHelper.java:624)
... ...
...ramework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframewor[email protected]1838ccb8] to prepare test instance [[email protected]]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
... ...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#0': Cannot create inner bean 'org.springframework.integration.config.ServiceActivatorFactoryBean#6ff29830' of type [org.springframework.integration.config.ServiceActivatorFactoryBean] while setting bean property 'handlers' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#6ff29830': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Target object of type [class com.project.dao.account.GetAccountsDAO$$EnhancerByMockitoWithCGLIB$$83f498fd] has no eligible methods for handling Messages.
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
... ...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#6ff29830': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Target object of type [class com.project.dao.account.GetAccountsDAO$$EnhancerByMockitoWithCGLIB$$83f498fd] has no eligible methods for handling Messages.
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:109)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:275)
... 49 more
... ...
Caused by: java.lang.IllegalArgumentException: Target object of type [class com.project.dao.account.GetAccountsDAO$$EnhancerByMockitoWithCGLIB$$83f498fd] has no eligible methods for handling Messages.
at org.springframework.util.Assert.notEmpty(Assert.java:294)
at org.springframework.integration.util.MessagingMethodInvokerHelper.findHandlerMethodsForTarget(MessagingMethodInvokerHelper.java:352)
Fragen zur Debugging-Hilfe? Sie haben nicht den gesamten Code zum Ausführen eines Beispiels bereitgestellt. Erstelle MCVE und poste es anstelle des Produktionscodes. –
@RomanC, ich stimme zu, dass die Frage für ein breiteres Publikum nicht völlig klar ist. Aber ich sehe was vor sich geht und gebe eine Antwort auf die Frage. Der Typ sollte nur lernen, wie man Fragen stellt. Aber das bedeutet nicht, dass wir es schließen müssen, wenn eine Bearbeitung noch möglich ist. –
@ArtemBilan Fragen ohne klare Problemstellung + Kommentar oben sollte so bald wie möglich geschlossen werden SO vergessen Sie mir, ich bin mehr als 5 Jahre auf SO, das ... antwortend. Keine Upvotes, keine akzeptiert, nur .... Benutzer wird gelöscht –