Java AI Framework Selection: Choose by Architectural Layer, Not Feature Lists

This guide categorizes Java AI frameworks into infrastructure and orchestration layers, comparing Spring AI, LangChain4j, Solon AI, Spring AI Alibaba, AgentScope, and Embabel with code examples, version requirements, and decision criteria for matching frameworks to project constraints and use cases.

Su San Talks Tech
Su San Talks Tech
Su San Talks Tech
Java AI Framework Selection: Choose by Architectural Layer, Not Feature Lists

Introduction: The Layering Problem

The article opens with a typical scenario: a team arguing over Spring AI, LangChain4j, and AgentScope for an intelligent customer service system. Each argument is valid but addresses a different layer. The core insight: these frameworks solve fundamentally different problems . Selection fails when teams compare feature lists instead of identifying which architectural layer they need.

Two-Layer Architecture

Rod Johnson's analogy (via Embabel launch) maps Java AI frameworks to Spring's own layers:

Infrastructure Layer (analogy: Servlet API) — Representative frameworks: Spring AI, LangChain4j, Solon AI. These handle how to connect LLMs, manage embeddings, and integrate vector stores .

Agent Orchestration Layer (analogy: Spring MVC) — Representative frameworks: Spring AI Alibaba, AgentScope, Embabel. These handle how to make agents reliably execute multi-step tasks in complex business flows .

The two layers are complementary, not competitive.

Layer 1: Infrastructure — Connecting AI

3.1 Spring AI 2.0: Spring's Official Abstraction

Released GA on June 12, 2026, built on Spring Boot 4.1 and Spring Framework 7.0. Key changes from 1.x:

Clear ChatClient/ChatModel boundary : ChatClient is the high-level user API with built-in Advisor chain; ChatModel is the low-level model abstraction for framework developers.

Tool-calling refactor : 1.x embedded proprietary tool-execution loops per model (OpenAI, Ollama, Anthropic). 2.0 moves the loop into the Advisor chain, unifying behavior and enabling composable loops (re-entry for structured-output retries, evaluation loops, etc.).

// Spring AI 2.0 tool calling
String response = ChatClient.create(chatModel)
    .prompt("明天是星期几?")
    .tools(new DateTimeTools())
    .call()
    .content();

When to use : Spring Boot 4.x projects, team knows Spring ecosystem, need fast AI integration. Trade-off: requires Java 21+.

3.2 LangChain4j: JVM's AI Toolbox

Started early 2023, v1.19.0 as of Sept 2026. Richest model (30+) and vector-store coverage. Core difference: Spring AI optimizes integration efficiency; LangChain4j optimizes scenario capability .

Spring AI: native Spring integration, declarative @AiService, auto-configuration, Starters.

LangChain4j: framework-neutral (Quarkus, Micronaut, plain Java), mature Agent mechanism for multi-step logic.

// LangChain4j declarative AI service
interface Assistant {
  @SystemMessage("你是一个Java技术顾问,请用中文回答")
  String chat(@UserMessage String question);
}

Assistant assistant = AiServices.create(Assistant.class, model);
String answer = assistant.chat("什么是虚拟线程?");

When to use : Need broadest model/vector-store support or non-Spring stack. Trade-off: less concise syntax, higher learning cost. Note: MCP protocol reached stability in 1.19 (July 2026 spec: stateless Streamable HTTP, no protocol-level session).

3.3 Solon AI: Full-Spectrum, Full-Version Compatibility

Core Solon subproject. Two unique traits:

Java 8–26 support — rare among Java AI frameworks (Spring AI 2.0 needs 21+, LangChain4j needs 17+).

Embeddable in any framework — Spring Boot, Vert.x, Quarkus, JFinal without binding to Solon.

// Solon AI builder API
ChatModel chatModel = ChatModel.of("http://127.0.0.1:11434/api/chat")
    .provider("ollama")
    .model("qwen2.5:1.5b")
    .build();

AssistantMessage result = chatModel.prompt("杭州今天天气怎么样?")
    .options(op -> op.toolAdd(new WeatherTools()))
    .call()
    .getMessage();

Provides three-tier Agent architecture: SimpleAgent → ReActAgent → TeamAgent. When to use : Java 8/11 projects or need a framework-agnostic AI capability layer.

Layer 2: Agent Orchestration — Organizing AI Work

4.1 Spring AI Alibaba: Enterprise Multi-Agent & Workflow

Co-maintained by Spring and Alibaba communities, open-sourced Sept 2024, 10k+ GitHub stars. Builds on Spring AI, adding upward abstraction and feature enhancement : Agent orchestration, Graph workflow engine, MCP dual-end support, enterprise governance.

Three-layer architecture:

Agent Framework — ReactAgent core.

Graph — low-level workflow/multi-agent coordination runtime.

Augmented LLM — Spring AI atomic abstractions (model, tools, MCP, vector store).

// Spring AI Alibaba ReactAgent
DashScopeApi dashScopeApi = DashScopeApi.builder()
    .apiKey(System.getenv("AI_DASHSCOPE_API_KEY"))
    .build();
ChatModel chatModel = DashScopeChatModel.builder()
    .dashScopeApi(dashScopeApi)
    .build();

ReactAgent agent = ReactAgent.builder()
    .name("weather_agent")
    .model(chatModel)
    .instruction("You are a helpful weather forecast assistant.")
    .build();

agent.call("what is the weather in Hangzhou?");

v1.1.2.0 adds Agent Skills (progressive disclosure of reusable instructions/context, reducing token use) and parallel multi-agent execution (LlmRouting, Supervisor patterns). When to use : Spring Boot projects building enterprise multi-agent systems or workflow orchestration (smart customer service, approval flows, data pipelines). Deep Alibaba Cloud integration (Qwen, Bailian, Higress AI Gateway, Nacos).

4.2 AgentScope Java 2.0: Enterprise Distributed Agent Foundation

GA June 2026. Used across 10+ core Alibaba business lines in production. Core: ReActAgent kernel + Harness engineering layer (Workspace, persistent memory, Session, Sandbox, Skill, Subagent). Developers can stay lightweight or enable enterprise-grade capabilities incrementally.

// AgentScope HarnessAgent
var agent = HarnessAgent.builder()
    .name("coder")
    .model("dashscope:qwen-max")
    .workspace(Paths.get(".agentscope/workspace"))
    .filesystem(new DockerFilesystemSpec())
    .isolationScope(IsolationScope.USER)
    .build();

agent.call(msg, RuntimeContext.builder()
    .sessionId("demo")
    .userId("alice")
    .build()).block();

Three differentiators: identity continuity, controllable context, recoverable state . Workspace = agent persona & long-term memory (auto-injected per turn); context auto-compression, large tool results spilled to disk, ContextOverflow fallback retry; same sessionId restores full conversation across processes, sandbox state snapshots. When to use : Enterprise multi-agent distributed systems needing long-running stability, multi-tenant isolation, tool-permission control.

4.3 Embabel: Deterministic GOAP Planning

Rod Johnson's JVM-native agent framework, 1.0.0 GA Aug 2026. Core: GOAP (Goal-Oriented Action Planning) — a game-AI planning algorithm. Unlike LLM-driven planning (hallucination-prone, non-deterministic), GOAP searches action sequences from preconditions/effects, producing explainable, auditable plans.

Built on Spring AI, reuses its model connections, @Tool, ChatClient. When to use : Scenarios requiring auditable, deterministic multi-step orchestration — financial compliance, medical decisions, supply-chain scheduling.

Framework Comparison

Infrastructure Layer

Spring AI — Layer: Infrastructure. Core Positioning: Spring ecosystem AI abstraction. Java Version: 21+. Framework Dependency: Strong Spring Boot. Best For: Spring Boot projects quick AI integration.

LangChain4j — Layer: Infrastructure. Core Positioning: JVM AI toolbox. Java Version: 17+. Framework Dependency: Framework-neutral. Best For: Rich model/vector-store support, non-Spring.

Solon AI — Layer: Infrastructure. Core Positioning: Full-scenario AI dev framework. Java Version: 8–26. Framework Dependency: Embeddable anywhere. Best For: Java 8/11 projects, framework-agnostic AI layer.

Orchestration Layer

Spring AI Alibaba — Layer: Orchestration. Core Positioning: Enterprise multi-agent & workflow. Java Version: 17+. Framework Dependency: Based on Spring AI. Best For: Multi-agent collaboration, workflow orchestration.

AgentScope — Layer: Orchestration. Core Positioning: Enterprise distributed Agent. Java Version: 17+. Framework Dependency: Framework-neutral. Best For: Multi-agent collaboration, production deployment.

Embabel — Layer: Orchestration. Core Positioning: Deterministic GOAP orchestration. Java Version: 17+. Framework Dependency: Based on Spring AI. Best For: Auditable, deterministic process orchestration.

Decision Logic

6.1 Tech Stack

Tech stack decision flowchart
Tech stack decision flowchart

6.2 Scenario Needs

Scenario needs decision flowchart
Scenario needs decision flowchart

6.3 Three Key Judgments

Java version? Java 8/11 → only Solon AI.

Monolith or distributed? Simple → Spring AI/LangChain4j. Enterprise distributed multi-agent → Spring AI Alibaba/AgentScope.

Need determinism? Finance/medical/gov → Embabel's GOAP (every decision traceable, explainable).

Pros/Cons Summary

Spring AI 2.0

Pros: Official Spring, deep Boot 4.x integration, elegant Advisor chain, composable tool calls, solid auto-config/observability.

Cons: Hard dependency on Spring Boot 4.x & Java 21+, no Java 8/11/17, awkward outside Spring.

Fit: Spring Boot 4.x quick AI integration.

LangChain4j

Pros: 30+ models out of box, widest vector-store coverage, framework-neutral, mature MCP support.

Cons: Verbose syntax, higher learning curve, faster iteration → less API stability.

Fit: Rich model/vector-store needs or non-Spring stacks.

Solon AI

Pros: Only framework supporting Java 8–26 ; embeddable in Spring Boot, Vert.x, Quarkus; three-tier Agent architecture.

Cons: Smaller ecosystem/community; mainly Chinese docs.

Fit: Java 8/11 projects or framework-agnostic AI layer.

Spring AI Alibaba

Pros: Spring AI + Alibaba Cloud full stack; Agent Framework + Graph workflow; Agent Skills (token-saving progressive disclosure); parallel multi-agent; deep Qwen/Bailian/Higress/Nacos integration.

Cons: Relatively new (Sept 2024), ecosystem building; Spring-centric.

Fit: Spring Boot enterprise multi-agent systems, workflow orchestration.

AgentScope

Pros: 10+ Alibaba production lines validated; Harness layer (Workspace, persistent memory, sandbox isolation, permission control); distributed deployment support.

Cons: Many concepts, steep learning curve; overkill for simple scenarios.

Fit: Enterprise multi-agent distributed systems.

Embabel

Pros: GOAP deterministic planning (no LLM reliance), explainable/auditable, builds on Spring AI (reuse @Tool, ChatClient).

Cons: Core in Kotlin (Java-compatible); new, ecosystem nascent.

Fit: Financial compliance, medical decisions, deterministic orchestration needs.

Final Recommendation: Three-Step Selection

Identify your layer : Infrastructure (connect AI) vs. Orchestration (organize AI work).

List constraints : Java version, framework, team familiarity, compliance requirements — cuts options in half.

Match core scenario : RAG, multi-agent, workflow, deterministic orchestration, simple integration — each maps to different framework strengths.

Avoid feature-list comparisons ("30 vector stores vs 15" — you'll use one). Ask: What capability does my project need most, and which framework is strongest there? The right fit is the best.

References

Spring AI docs: https://docs.spring.io/spring-ai

LangChain4j docs: https://docs.langchain4j.dev

Solon AI docs: https://solon.noear.org

Spring AI Alibaba docs: https://java2ai.com

Spring AI Alibaba GitHub: https://github.com/alibaba/spring-ai-alibaba

AgentScope Java docs: https://java.agentscope.io

Embabel docs: https://docs.embabel.com

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Spring AILangChain4jframework selectionSpring AI AlibabaAgentScopeJava AI frameworksSolon AIEmbabel
Su San Talks Tech
Written by

Su San Talks Tech

Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.