# xiaoail-spring **Repository Path**: luo-answer/xiaoai-spring ## Basic Information - **Project Name**: xiaoail-spring - **Description**: 手撕spring,主要是自己学习一下spring源码 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-09-07 - **Last Updated**: 2026-09-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # xiaoai-spring This is a simple Spring IoC (Inversion of Control) container implementation that demonstrates the core principles of the Spring framework. ## Project Introduction xiaoai-spring is a lightweight implementation designed for learning the core mechanisms of the Spring framework, including basic Bean container functionalities. Through this project, you can understand the most core IoC and Bean management mechanisms in the Spring framework. ## Core Features ### BeanDefinition `BeanDefinition` is the definition class for Beans, used to store basic Bean information: - Stores Bean instance objects - Provides methods to retrieve Beans ### BeanFactory `BeanFactory` is the factory class for Beans, the core container: - Manages BeanDefinition registration - Provides Bean retrieval functionality - Maintains BeanDefinition mapping relationships ## Project Structure ``` xiaoai-spring/ ├── pom.xml # Maven project configuration └── src/ ├── main/java/cn/xiaoai/springframework/ │ ├── BeanDefinition.java # Bean definition class │ └── BeanFactory.java # Bean factory class └── test/java/cn/xiaoai/springframework/test/ ├── ApiTest.java # API test class └── bean/ └── UserService.java # Example Bean ``` ## Quick Start ### Environment Requirements - JDK 8 or higher - Maven 3.0+ ### Build Project ```bash mvn clean install ``` ### Run Tests ```bash mvn test ``` ## Example Code ### 1. Define Bean ```java public class UserService { public void queryUserInfo() { System.out.println("Querying user information"); } } ``` ### 2. Register and Retrieve Bean ```java // Create BeanFactory BeanFactory beanFactory = new BeanFactory(); // Register Bean Definition beanFactory.registerBeanDefinition("userService", new BeanDefinition(new UserService())); // Retrieve Bean UserService userService = (UserService) beanFactory.getBean("userService"); userService.queryUserInfo(); ``` ## Tech Stack - **Language**: Java - **Build Tool**: Maven - **Test Framework**: JUnit ## License This project is for learning purposes only. ## Contributing Welcome to submit Issues and Pull Requests.