Skip to content

jumpman-cmd/spring-boot-user-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot User Management Demo

Overview

This is a simple Spring Boot project that demonstrates basic concepts like dependency injection, annotations, and in-memory data storage.

Technologies Used

  • Java 17
  • Spring Boot
  • JUnit 5 for testing

How to Run

  1. Clone the repository

  2. Run the project with the command: ./gradlew bootRun

  3. The console will show user interactions.

How to Test

  1. Run tests with: ./gradlew test

Project Structure

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

How It Works

  1. User Model: Represents a user with id, name, and surname.
  2. Fake Repository: Simulates a database with in-memory storage. It can insert, find, and delete users.
  3. User Service: Implements business logic for adding, getting, and removing users.
  4. Controller (optional): (For advanced learners, not included in this example).

Key Features

  • Dependency Injection: Used to inject dependencies like FakeRepo into UserService.
  • Layered Architecture: The project is divided into models, repository, and services.
  • Unit Testing: Includes tests for service methods.

Code Standards

  • 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).

Git Workflow

  • Main Branch: Stable code.
  • Develop Branch: For new features.
  • Feature Branches: For individual features (e.g., feature/add-user).

Commit Messages Format:

  • feat: Added FakeRepo with in-memory storage
  • fix: Corrected method name in UserService
  • test: Added unit tests for addUser

Conclusion

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.

Resources

About

A simple Spring Boot demo showcasing basic dependency injection, annotations, and in-memory user management. Includes a layered architecture (model, repo, service) and JUnit 5 tests. Run with ./gradlew bootRun, test with ./gradlew test.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages