系列Java工程师转AI Agent 3个月学习计划作者宸丶一| 28岁Java程序员今日目标理解Spring Boot Starter原理开发Java Agent Starter个人格言代码改不改变世界我不知道但先让我准时下班。前言昨天用gRPC让Python Agent调用Java服务今天要用Spring Boot Starter封装Agent能力Spring Boot Starter是Java生态的核心概念之一理解它对于开发Java Agent至关重要。这次直接用MiMo Code生成了一个starter然后自己做代码Review发现了7个问题。这种体验工具→发现问题→理解原理的学习方式比光看文档有效多了。学习目标理解Spring Boot Starter原理用MiMo Code开发Java Agent Starter理解Starter在Agent架构中的价值一、Spring Boot Starter原理什么是StarterStarter 空壳依赖聚合包 自动配置模块Starter内部Starter用户引入依赖自动配置开箱即用空壳pom.xmlAutoConfigurationProperties配置类比JavaSpring Boot Starter ≈ Maven Archetype ├── 预定义的依赖 ├── 预定义的配置 └── 开箱即用Starter的标准结构agent-spring-boot/ # 父模块 ├── agent-spring-boot-starter/ # 空壳依赖聚合pom.xml │ └── pom.xml # 依赖autoconfigure ├── agent-spring-boot-autoconfigure/ # 自动配置核心 │ └── src/main/java/... # 所有代码 └── pom.xml # 父pomspring.factoriesorg.springframework.boot.autoconfigure.EnableAutoConfiguration\ com.example.agent.AgentAutoConfiguration二、用MiMo Code生成Starter生成的项目结构agent-spring-boot-starter/ ├── pom.xml ├── src/main/java/com/example/agent/ │ ├── Agent.java # Agent核心类 │ ├── AgentApplication.java # 示例应用 │ ├── AgentAutoConfiguration.java # 自动配置 │ ├── AgentManager.java # Agent管理器 │ └── AgentProperties.java # 配置属性 ├── src/main/resources/META-INF/ │ └── spring.factories # 注册自动配置 └── target/ # 已编译成功关键代码AgentAutoConfigurationConfigurationConditionalOnClass(Agent.class)EnableConfigurationProperties(AgentProperties.class)ConditionalOnProperty(prefixagent,nameenabled,havingValuetrue,matchIfMissingtrue)publicclassAgentAutoConfiguration{AutowiredprivateAgentPropertiesagentProperties;BeanConditionalOnMissingBeanpublicAgentagent(){AgentagentnewAgent();agent.setName(agentProperties.getName());agent.setType(agentProperties.getType());agent.setVersion(agentProperties.getVersion());returnagent;}BeanConditionalOnMissingBeanpublicAgentManageragentManager(Agentagent){returnnewAgentManager(agent);}}AgentPropertiesConfigurationProperties(prefixagent)publicclassAgentProperties{privatebooleanenabledtrue;privateStringnamedefault-agent;privateStringtypegeneral;privateStringversion1.0.0;privatebooleandebugfalse;privateintmaxConcurrentRequests10;privatelongrequestTimeout30000;// getters and setters}三、代码Review发现7个问题生成完代码后我自己做了一遍Review发现了7个关键问题问题严重度修复建议pom.xml循环依赖自己依赖自己⚠️ 高删掉那个依赖Starter应该拆成两个模块⚠️ 中starter autoconfigureAgentApplication在starter里⚠️ 中移到单独example模块Agent类太简单没有LLM/Tool/Memory⚠️ 中后续迭代添加AgentManager不是真正的多Agent系统⚠️ 低后续迭代添加缺少LLM配置apiKey/baseUrl/model⚠️ 中AgentProperties添加Spring Boot版本过旧2.7.18⚠️ 低后续升级3.x问题1pom.xml循环依赖!-- 这里有问题自己依赖自己 --dependencygroupIdcom.example/groupIdartifactIdagent-spring-boot-starter/artifactIdversion1.0.0-SNAPSHOT/version/dependency问题2Starter应该拆成两个模块标准的Spring Boot Starter应该有两个模块agent-spring-boot/ # 父模块 ├── agent-spring-boot-starter/ # 空壳依赖聚合pom.xml │ └── pom.xml # 依赖autoconfigure ├── agent-spring-boot-autoconfigure/ # 自动配置核心 │ └── src/main/java/... # 所有代码 └── pom.xml # 父pom四、今日收获知识层面理解了Spring Boot Starter原理掌握了Starter的标准结构starter autoconfigure理解了Starter在Agent架构中的价值技能层面能用MiMo Code生成Starter代码能发现代码中的关键问题循环依赖、模块拆分理解了条件注解的使用场景思维层面学会了代码Review发现了7个问题理解了标准结构的重要性理解了Starter和实际产品的差距五、思考题答案1. Starter的作用Starter 空壳依赖聚合包 自动配置模块依靠AutoConfiguration.imports注册配置类 条件注解按需创建Bean做到引入依赖即可自动装配组件。2. 为什么需要Starter痛点1原生Spring依赖繁琐 / 痛点2大量XML/JavaConfig配置 / 痛点3组件集成标准不统一。3. 核心组件xxx-spring-boot-starter空壳 → xxx-spring-boot-autoconfigure核心4. 什么场景用经常被调用的比如agent工具、内部的mcp实现。5. Agent架构中的价值开箱即用循环以及复杂任务拆成简单任务执行时可以省去很多麻烦。6. 如何设计Agent Starter大模型、工具、协同、通信、记忆等多方面都要涉及。7. Starter vs ArchetypeStarter是项目启动才开始加载和配置以及测试Maven的话是外部的启动前就会校验。8. 新认识开箱即用可以把很多东西都做成可配置的这样就会刚好适配。六、明日计划明天继续深入分析多Agent系统实现小小腾老师的评分维度得分评价Starter掌握程度⭐⭐⭐⭐理解原理但标准结构还需要深入代码实践⭐⭐⭐⭐能用MiMo Code生成但有问题需要修复思考题⭐⭐⭐⭐80分部分答案可以更完整代码Review⭐⭐⭐⭐⭐发现了7个关键问题总分80分良好老师说今天用MiMo Code生成了starter还做了代码Review发现了关键问题明天继续加油