This is a simple Spring Boot project that demonstrates basic concepts like dependency injection, annotations, and in-memory data storage.
- Java 17
- Spring Boot
- JUnit 5 for testing
-
Clone the repository
-
Run the project with the command: ./gradlew bootRun
-
The console will show user interactions.
- Run tests with: ./gradlew test
spring-boot-user-demo/
│
├── src/
│ │
│ ├── main/
│ │ ├── java/com/example/demo/
│ │ │ ├── DemoApplication.java
│ │ │ ├── model/User.java
│ │ │ ├── repo/FakeRepoInterface.java
│ │ │ ├── repo/FakeRepo.java
│ │ │ ├── service/UserService.java
│ │ │ ├── service/UserServiceImpl.java
│ │ └── test/
│ │ └── java/com/example/demo/
│ │ └── service/UserServiceTests.java
│
├── build.gradle
├── README.md
- User Model: Represents a user with
id,name, andsurname. - Fake Repository: Simulates a database with in-memory storage. It can insert, find, and delete users.
- User Service: Implements business logic for adding, getting, and removing users.
- Controller (optional): (For advanced learners, not included in this example).
- Dependency Injection: Used to inject dependencies like
FakeRepointoUserService. - Layered Architecture: The project is divided into models, repository, and services.
- Unit Testing: Includes tests for service methods.
- Use camelCase for variables and methods.
- Use PascalCase for class names.
- Follow OOP principles (Encapsulation, Abstraction).
- Write clear and meaningful code comments.
- Test edge cases (e.g., invalid inputs, empty states).
- Main Branch: Stable code.
- Develop Branch: For new features.
- Feature Branches: For individual features (e.g.,
feature/add-user).
feat: Added FakeRepo with in-memory storagefix: Corrected method name in UserServicetest: Added unit tests for addUser
This project is a simple introduction to Spring Boot, focusing on core concepts like dependency injection and layered architecture. It's designed to help you understand the basics of Spring Boot and improve your Java development skills.