CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-springframework-ai--spring-ai-spring-boot-autoconfigure

Spring AI Spring Boot Auto Configuration modules providing automatic setup for AI models, vector stores, MCP, and retry capabilities

Overview
Eval results
Files

native-image.mddocs/reference/

AOT and GraalVM Native Image Support

Spring AI autoconfiguration includes built-in support for Ahead-of-Time (AOT) compilation and GraalVM native images.

Overview

Runtime hints are automatically registered for reflection, resource access, proxy generation, and serialization.

MCP Client Runtime Hints

/**
 * Runtime hints registrar for MCP client common module
 * 
 * Location: mcp-client-common/aot/McpClientAutoConfigurationRuntimeHints.java
 * Registered in: META-INF/spring/aot.factories
 * 
 * Registers:
 * - Reflection hints for MCP schema classes
 * - Resource patterns for JSON schemas
 * - Serialization hints for protocol types
 * - Proxy hints for client interfaces
 */
class McpClientAutoConfigurationRuntimeHints implements RuntimeHintsRegistrar {
    @Override
    public void registerHints(RuntimeHints hints, ClassLoader classLoader);
}

/**
 * Runtime hints registrar for Apache HttpClient-based MCP transports
 * 
 * Location: mcp-client-httpclient/aot/McpClientAutoConfigurationRuntimeHints.java
 */
class McpClientAutoConfigurationRuntimeHints implements RuntimeHintsRegistrar {
    @Override
    public void registerHints(RuntimeHints hints, ClassLoader classLoader);
}

/**
 * Runtime hints registrar for WebFlux-based MCP transports
 * 
 * Location: mcp-client-webflux/aot/McpClientAutoConfigurationRuntimeHints.java
 */
class McpClientAutoConfigurationRuntimeHints implements RuntimeHintsRegistrar {
    @Override
    public void registerHints(RuntimeHints hints, ClassLoader classLoader);
}

AOT Factories Configuration

# META-INF/spring/aot.factories
org.springframework.aot.hint.RuntimeHintsRegistrar=\
  org.springframework.ai.mcp.client.common.autoconfigure.aot.McpClientAutoConfigurationRuntimeHints,\
  org.springframework.ai.mcp.client.httpclient.autoconfigure.aot.McpClientAutoConfigurationRuntimeHints,\
  org.springframework.ai.mcp.client.webflux.autoconfigure.aot.McpClientAutoConfigurationRuntimeHints

Building Native Images

# Build native image with Maven
./mvnw -Pnative native:compile

# Build native image with Gradle
./gradlew nativeCompile

# Run native executable
./target/my-spring-ai-app

# Build Docker image with native executable
./mvnw -Pnative spring-boot:build-image

Custom Runtime Hints

For custom classes, provide runtime hints:

@Configuration
public class CustomRuntimeHints {
    
    @Bean
    public RuntimeHintsRegistrar customHints() {
        return (hints, classLoader) -> {
            // Register custom classes
            hints.reflection()
                .registerType(MyCustomTool.class, 
                    MemberCategory.INVOKE_PUBLIC_METHODS);
            
            // Register resources
            hints.resources()
                .registerPattern("custom/*.json");
            
            // Register for serialization
            hints.serialization()
                .registerType(MyCustomTool.class);
        };
    }
}

Supported Features in Native Images

✅ Chat models, embedding models, and image models
✅ MCP client and server functionality (all transports)
✅ Vector stores (all 20 implementations)
✅ Retry and observation capabilities
✅ Tool calling and function callbacks
✅ Chat memory with all repository backends
✅ Spring Cloud Bindings integration

Troubleshooting Native Images

# Collect runtime hints using agent
java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image \
     -jar target/my-app.jar

# Enable verbose native image build
./mvnw -Pnative native:compile -Dverbose

# Test native image locally before deployment
./target/my-spring-ai-app

See Edge Cases for Native Image Issues →

Install with Tessl CLI

npx tessl i tessl/maven-org-springframework-ai--spring-ai-spring-boot-autoconfigure@1.1.0

docs

index.md

tile.json