This is a simple Spring Core (Annotation-Based Configuration) project that demonstrates the use of:
- Dependency Injection (DI)
- Component Scanning
- @Autowired Annotation
- Layered Architecture (Service + Bean)
This application simulates a basic laptop management system where:
- A
Laptopobject holds configuration details - A
LaptopServiceclass accesses and displays those details - Spring manages object creation and dependency injection
- Java
- Spring Core
- Annotation-based Configuration
com.nit │
├── config
│ └── AppConfig.java
│ ├── sbeans
│ ├── Laptop.java
│ └── LaptopService.java
│ └── main
└── TestApp.java
Spring configuration is handled using Java-based configuration with @Configuration and @ComponentScan.
📄 File: AppConfig.java
:contentReference[oaicite:0]{index=0}
- Annotated with
@Component - Stores laptop details like brand, processor, and RAM
📄 File: Laptop.java
:contentReference[oaicite:1]{index=1}
- Annotated with
@Service - Uses
@Autowiredto inject Laptop dependency - Prints laptop details
📄 File: LaptopService.java
:contentReference[oaicite:2]{index=2}
- Loads Spring container
- Retrieves beans from context
- Sets laptop details
- Calls service method to display data
📄 File: TestApp.java
:contentReference[oaicite:3]{index=3}
- Clone the repository
- Import into your IDE (Eclipse/IntelliJ)
- Ensure Spring Core dependencies are added
- Run
TestApp.java
Laptop Brand: Dell Processor: Intel i7 Ram: 16 GB
- @Component → Marks a class as Spring Bean
- @Service → Specialized component for service layer
- @Autowired → Automatic dependency injection
- @Configuration → Java-based configuration
- @ComponentScan → Scans package for beans
This project is a basic example of how Spring Core manages object creation and dependency injection using annotations. It helps in understanding the fundamental concepts required for building scalable Java applications.
Developed as part of learning Spring Framework 🚀