一、问题描述
1、应用场景
- 测试大模型使用 MCP 服务
2、异常信息
org.springframework.beans.factory.BeanCreationException: Error creating bean with name'mcpClientCallBaiDuMcpController':Injection of resource dependencies failed at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:372)~[spring-context-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1459)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1222)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1188)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1123)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987)~[spring-context-6.2.10.jar:6.2.10]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)~[spring-context-6.2.10.jar:6.2.10]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)~[spring-boot-3.5.5.jar:3.5.5]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)~[spring-boot-3.5.5.jar:3.5.5]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)~[spring-boot-3.5.5.jar:3.5.5]at org.springframework.boot.SpringApplication.run(SpringApplication.java:318)~[spring-boot-3.5.5.jar:3.5.5]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361)~[spring-boot-3.5.5.jar:3.5.5]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350)~[spring-boot-3.5.5.jar:3.5.5]at com.atguigu.study.Saa16ClientCallBaiduMcpServerApplication.main(Saa16ClientCallBaiduMcpServerApplication.java:12)~[classes/:na]Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name'chatClient'definedinclass path resource[com/atguigu/study/config/SaaLLMConfig.class]: Unsatisfied dependency expressed through method'chatClient'parameter0: Error creating bean with name'dashscopeChatModel'definedinclass path resource[com/alibaba/cloud/ai/autoconfigure/dashscope/DashScopeChatAutoConfiguration.class]: Unsatisfied dependency expressed through method'dashscopeChatModel'parameter1: Error creating bean with name'toolCallingManager'definedinclass path resource[org/springframework/ai/model/tool/autoconfigure/ToolCallingAutoConfiguration.class]: Unsatisfied dependency expressed through method'toolCallingManager'parameter0: Error creating bean with name'toolCallbackResolver'definedinclass path resource[org/springframework/ai/model/tool/autoconfigure/ToolCallingAutoConfiguration.class]: Unsatisfied dependency expressed through method'toolCallbackResolver'parameter2: Error creating bean with name'mcpToolCallbacks'definedinclass path resource[org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfiguration.class]: Failed to instantiate[org.springframework.ai.mcp.SyncMcpToolCallbackProvider]: Factory method'mcpToolCallbacks'threw exception with message: Error creating bean with name'mcpSyncClients'definedinclass path resource[org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfiguration.class]: Failed to instantiate[java.util.List]: Factory method'mcpSyncClients'threw exception with message: java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 20000msin'source(MonoDeferContextual)'(and no fallback has been configured)at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:546)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1375)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1205)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)~[spring-beans-6.2.10.jar:6.2.10]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)~[spring-beans-6.2.10.jar:6.2.10]二、解决办法
安装 Node.js 参考