第3节:智能体配置表设计 首先我们需要安装对应的依赖父pom下dependency groupIdcom.google.adk/groupId artifactIdgoogle-adk/artifactId version0.4.0/version /dependency ​ dependency groupIdcom.google.adk/groupId artifactIdgoogle-adk-dev/artifactId version0.4.0/version /dependency ​ dependency groupIdcom.google.adk/groupId artifactIdgoogle-adk-spring-ai/artifactId version0.4.0/version /dependency ​ dependency groupIdcom.google.adk.samples/groupId artifactIdgoogle-adk-sample-helloworld/artifactId version0.4.0/version /dependency ​ dependency groupIdcom.google.adk/groupId artifactIdgoogle-adk-contrib-langchain4j/artifactId version0.2.0/version /dependency ​ !-- dependency-- !-- groupIddev.langchain4j/groupId-- !-- artifactIdlangchain4j-core/artifactId-- !-- version1.4.0/version-- !-- /dependency-- ​ !-- dependency-- !-- groupIddev.langchain4j/groupId-- !-- artifactIdlangchain4j-open-ai/artifactId-- !-- version1.4.0/version-- !-- /dependency-- ​ !-- spring ai 1.1.0 https://central.sonatype.com/artifact/org.springframework.ai/spring-ai-bom -- dependency groupIdorg.springframework.ai/groupId artifactIdspring-ai-bom/artifactId version1.1.0-M3/version typepom/type scopeimport/scope /dependency ​ !-- langchain4j https://mvnrepository.com/artifact/dev.langchain4j/langchain4j-bom -- dependency groupIddev.langchain4j/groupId artifactIdlangchain4j-bom/artifactId version1.4.0/version typepom/type scopeimport/scope /dependency ​ !-- 设计模式框架 -- dependency groupIdcn.bugstack.wrench/groupId artifactIdxfg-wrench-starter-design-framework/artifactId version3.0.0/version /dependency ​app目录下!-- spring ai google adk begin -- ​ dependency groupIdcom.google.adk/groupId artifactIdgoogle-adk/artifactId /dependency ​ dependency groupIdcom.google.adk/groupId artifactIdgoogle-adk-dev/artifactId /dependency ​ dependency groupIdcom.google.adk.samples/groupId artifactIdgoogle-adk-sample-helloworld/artifactId /dependency ​ dependency groupIdcom.google.adk/groupId artifactIdgoogle-adk-contrib-langchain4j/artifactId /dependency ​ dependency groupIdcom.google.adk/groupId artifactIdgoogle-adk-spring-ai/artifactId /dependency ​ dependency groupIddev.langchain4j/groupId artifactIdlangchain4j/artifactId /dependency ​ dependency groupIddev.langchain4j/groupId artifactIdlangchain4j-core/artifactId /dependency ​ dependency groupIddev.langchain4j/groupId artifactIdlangchain4j-open-ai/artifactId /dependency ​ dependency groupIdorg.springframework.ai/groupId artifactIdspring-ai-openai/artifactId /dependency ​ dependency groupIdorg.springframework.ai/groupId artifactIdspring-ai-starter-mcp-client-webflux/artifactId /dependency ​ !-- spring ai google adk end --需求分析以使用工程yml文件方式配置通用智能体配置表允许用户在使用脚手架创建完智能体工程后通过yml配置出自己需要的智能体再结合业务场景做对应的开发和衔接流程设计首先一个智能体配置所需的最基本信息包括应用名称、智能体描述、智能体模块主要的组件类配置都在智能体模块下AiApi 负责对接 AI 接口ChatModel 负责模型创建也会把 AiApi 对接之后还要创建出 MCP 工具。之后就是对于单一智能体的创建这里可以按顺序创建出很多智能体之后到AgentWorkflow 中进行编排构造出一个完整的智能体功能实现对象设计Data public class AiAgentConfigTableVO { ​ /** * 应用名称 */ private String appName; ​ /** * 智能体列表 */ private Agent agent; ​ ​ ​ Data public static class Agent{ ​ /** * 智能体ID */ private String agentId; ​ /** * 智能体名称 */ private String agentName; ​ /** * 智能体描述 */ private String agentDesc; } ​ Data public static class Module{ ​ private AiApi aiApi; ​ Data public static class AiApi{ ​ private String baseUrl; private String apiKey; private String completionsPath /v1/chat/completions; private String embeddingsPath /v1/embeddings; } ​ Data public static class ChatModel{ ​ private String model; private ListToolMcp toolMcpList; ​ Data public static class ToolMcp{ ​ private SSEServerParameters sse; ​ private StdioServerParameters stdio; ​ Data public static class SSEServerParameters { private String name; private String baseUri; private String sseEndpoint; private Integer requestTimeout 3000; ​ } ​ Data public static class StdioServerParameters { private String name; private Integer requestTimeout 3000; private ServerParameters serverParameters; ​ Data public static class ServerParameters { private String command; private ListString args; private MapString, String env; ​ } } } ​ Data public static class Agent { private String name; private String instruction; private String description; private String outputKey; ​ } ​ Data public static class AgentWorkflow { /** * 类型loop、parallel、sequential */ private String type; private String name; private ListString subAgents; private String description; private Integer maxIterations 3; ​ } } } }配置ymlspring: config: import: # - classpath:agent/test_agent_02.yml - classpath:agent/test_agent.yml ​配置类加载Slf4j Configuration EnableConfigurationProperties(AiAgentAutoConfigProperties.class) public class AiAgentAutoConfig implements ApplicationListenerApplicationReadyEvent { ​ Resource private AiAgentAutoConfigProperties aiAgentAutoConfigProperties; ​ Override public void onApplicationEvent(ApplicationReadyEvent event) { try { log.info(Ai Agent 智能体装配 {}, JSON.toJSONString(aiAgentAutoConfigProperties.getTables().values())); } catch (Exception e) { throw new RuntimeException(e); } } } ​EnableConfigurationProperties(xxx.class)是开启配置自动绑定ApplicationListener监听器ApplicationReadyEvent监听「SpringBoot 完全启动成功」这件事 ,onApplicationEvent()当项目启动完成 →自动调用这个方法