Spring / Spring AI interview questions
How does Spring AI integrate with Spring Boot auto-configuration?
Spring AI follows standard Spring Boot auto-configuration conventions, which means zero boilerplate for the common case. When you add a provider starter to your dependencies and supply the required properties, Spring Boot auto-configures the AI beans you need without any @Configuration classes on your part.
Each provider starter (e.g. spring-ai-openai-spring-boot-starter) ships a spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports file that registers its auto-configuration classes. Those classes use @ConditionalOnProperty and @ConditionalOnMissingBean guards so they activate only when needed and back off when you declare your own bean.
What gets auto-configured per provider:
- A
ChatModelbean (e.g.OpenAiChatModel). - An
EmbeddingModelbean if the provider supports embeddings. - A
ChatClient.Builderprototype bean that injects the auto-configuredChatModel. - Provider-specific
@ConfigurationPropertiesbindings (API keys, base URLs, default model names, timeouts).
Minimal application.properties for OpenAI:
spring.ai.openai.api-key=${OPENAI_API_KEY}
spring.ai.openai.chat.options.model=gpt-4o
spring.ai.openai.chat.options.temperature=0.7If you need to customise the HTTP client, add observability, or wire a custom RetryTemplate, declare a @Bean of the required type and Spring Boot's @ConditionalOnMissingBean will skip the auto-configured default in favour of yours.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
