A Library Management System built with Spring Boot 3, featuring JWT authentication, role-based access control, and a responsive web interface using Thymeleaf.
- JWT (JSON Web Token) authentication for API endpoints
- Session-based authentication for web pages (Thymeleaf)
- Role-based access control (User & Admin)
- Secure password hashing with BCrypt
- RESTful API for Books, Members, and Loans
- H2 in-memory database for easy setup
- CORS enabled for API
- Exception handling and input validation
- Demo data seeded on startup
# Go to the backend directory
cd library-management-utspbold
# Run with Maven (if installed globally)
mvn spring-boot:run
# Or with Maven wrapper (Windows)
mvnw.cmd spring-boot:run
# Or with Maven wrapper (Linux/Mac)
./mvnw spring-boot:runThe backend will run at http://localhost:8481
- Web Interface:
- Login:
http://localhost:8481/login - Home:
http://localhost:8481/ - Books:
http://localhost:8481/books - Members:
http://localhost:8481/members - Loans:
http://localhost:8481/loans
- Login:
- H2 Console:
http://localhost:8481/h2-console
| Username | Password | Role |
|---|---|---|
| Alogo | Alogo.24 | ADMIN |
| Ronaldo | Ronaldo.7 | USER |
POST /api/auth/login– Login user (JWT)POST /api/auth/register– Register new user (JWT)GET /api/auth/me– Get current user info (JWT)
GET /api/books– Get all booksPOST /api/books– Create new bookPUT /api/books/{id}– Update bookDELETE /api/books/{id}– Delete book
GET /api/members– Get all membersPOST /api/members– Create new memberPUT /api/members/{id}– Update memberDELETE /api/members/{id}– Delete member
GET /api/loans– Get all loansPOST /api/loans– Create new loanPUT /api/loans/{id}– Update loanDELETE /api/loans/{id}– Delete loan
- Spring Boot 3.x
- Spring Security (JWT & session-based)
- Spring Data JPA
- H2 Database
- Thymeleaf (for web pages)
- Maven
- Database: H2 in-memory, auto-created on startup
- Authentication:
- API endpoints use JWT
- Web pages use session-based login
- JWT Secret: Configured in
JwtUtil.javaandapplication.properties
On startup, the system seeds:
- 2 sample books
- 2 sample members
- 2 sample loan transactions
- Default users: admin/admin123 and user/user123
- Port 8481 already in use:
- Find and kill the process using the port (see README for commands)
- Maven not found:
- Use the Maven wrapper (
mvnw.cmdor./mvnw)
- Use the Maven wrapper (
- Authentication issues:
- Use default users or register a new one
- Database issues:
- H2 database is recreated on each startup
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to your branch
- Create a Pull Request
This project is licensed under the MIT License.