这是我的代码片段
@Bean
@ServiceActivator(inputChannel = "topicChannel", outputChannel="responseChannel")
public Employee getEmpDetails() throws Exception {
Expression query = new LiteralExpression("{'name' : '*****'}");
MongoDbMessageSource source = new MongoDbMessageSource(mongoDbFactory(), query);
source.setEntityClass(Employee.class);
source.afterPropertiesSet();
List<Employee> resluts =((List<Employee>)source.receive().getPayload());
return resluts.get(0);
}
下面是错误
java.lang.RuntimeException:在 org.springframework.integration.mongodb.inbound.MongoDbMessageSource.onInit(MongoDbMessageSource.java:176) 在 org.springframework.integration.expression.ExpressionUtils.createStandardEvaluationContext(ExpressionUtils.java:79) 没有 beanfactory .springframework.integration.context.IntegrationObjectSupport.afterPropertiesSet(IntegrationObjectSupport.java:150) at com.gap.si.configuratoin.MongoDBConfiguration.getEmpDetails(MongoDBConfiguration.java:48) at com.gap.si.configuratoin.MongoDBConfiguration$$EnhancerBySpringCGLIB$ $8e22c38.CGLIB$getEmpDetails$3() at com.gap.si.configuratoin.MongoDBConfiguration$$EnhancerBySpringCGLIB$$8e22c38$$FastClassBySpringCGLIB$$99782c25.invoke() at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309) at com.gap.si.configuratoin.MongoDBConfiguration$$EnhancerBySpringCGLIB$$8e22c38.getEmpDetails() at sun.reflect. NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method. java:483) 在 org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014) 在 org.springframework.beans 的 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119) .factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) 在 org.springframework.beans.factory.support.AbstractBeanFactory $1。 getObject(AbstractBeanFactory.java:303) 在 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)在 org.springframework.integration.config.annotation.ServiceActivatorAnnotationPostProcessor.createHandler(ServiceActivatorAnnotationPostProcessor.java:54) 在 org.springframework.integration.config.annotation.ServiceActivatorAnnotationPostProcessor.createHandler(ServiceActivatorAnnotationPostProcessor.java:54) 在 org.springframework.integration.config.annotation. .annotation.AbstractMethodAnnotationPostProcessor.postProcess(AbstractMethodAnnotationPostProcessor.java:117) 在 org.springframework.integration.config。annotation.MessagingAnnotationPostProcessor$1.doWith(MessagingAnnotationPostProcessor.java:151) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:495) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:502) at org. springframework.integration.config.annotation.MessagingAnnotationPostProcessor.postProcessAfterInitialization(MessagingAnnotationPostProcessor.java:131) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422) at org.springframework.beans.factory.support。 AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) 在 org.springframework.beans.factory.support。AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java :303) 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) 在 org.springframework.getSingleton(DefaultSingletonBeanRegistry.java:230)。 beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) 在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) 在 org.springframework.boot.context.embedded 的 org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) .EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) 在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 在 org.springframework。 boot.SpringApplication.run(SpringApplication.java:957) at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) at com.gap.si.configuratoin.Application.main(Application.java:16)springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh( EmbeddedWebApplicationContext.java:118) 在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 在 org.springframework.boot.SpringApplication.run (SpringApplication.java:957) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 在 com.gap.si.configuratoin.Application.main(Application.java:16)springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh( EmbeddedWebApplicationContext.java:118) 在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 在 org.springframework.boot.SpringApplication.run (SpringApplication.java:957) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 在 com.gap.si.configuratoin.Application.main(Application.java:16)AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:957 ) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 在 com.gap.si.configuratoin.Application.main(Application.java:16)AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:957 ) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 在 com.gap.si.configuratoin.Application.main(Application.java:16)第757章.refresh(SpringApplication.java:686) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:957) 在 org.springframework.boot。 SpringApplication.run(SpringApplication.java:946) 在 com.gap.si.configuratoin.Application.main(Application.java:16)第757章.refresh(SpringApplication.java:686) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:320) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:957) 在 org.springframework.boot。 SpringApplication.run(SpringApplication.java:946) 在 com.gap.si.configuratoin.Application.main(Application.java:16)Embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework .boot.SpringApplication.run(SpringApplication.java:957) at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) at com.gap.si.configuratoin.Application.main(Application.java:16)Embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework .boot.SpringApplication.run(SpringApplication.java:957) at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) at com.gap.si.configuratoin.Application.main(Application.java:16)java:957) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 在 com.gap.si.configuratoin.Application.main(Application.java:16)java:957) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:946) 在 com.gap.si.configuratoin.Application.main(Application.java:16)