A secure Employee Management REST API built using:
- Spring Boot 4
- Spring Data JPA
- Hibernate ORM
- MySQL
- Spring Security (HTTP Basic Authentication)
- Lombok
- Postman (for API testing)
This project demonstrates:
- REST API development
- CRUD operations using Spring Data JPA
- MySQL database integration
- Spring Security configuration
- Layered architecture (Controller → Service → Repository → Database)
All API endpoints are secured using HTTP Basic Authentication.
Controller → Service → Repository (DAO) → Database
Controller Layer
- Handles HTTP requests and responses.
Service Layer
- Contains business logic.
Repository Layer
- Extends JpaRepository to perform database operations.
Entity Layer
- Represents database table structure.
CREATE DATABASE springbootdatajparestsecurity;spring.datasource.url=jdbc:mysql://localhost:3306/springbootdatajparestsecurity
spring.datasource.username=root
spring.datasource.password=your_password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect@Configuration
@EnableWebSecurity
public class Config {
@Bean
public SecurityFilterChain configure(HttpSecurity security) {
security.authorizeHttpRequests(auth -> auth.anyRequest().authenticated());
security.csrf(csrf -> csrf.disable());
security.httpBasic(Customizer.withDefaults());
return security.build();
}
}- All endpoints require authentication
- Uses HTTP Basic Authentication
- CSRF disabled (for REST API testing)
- Spring generates a temporary password on startup
Example console output:
Using generated security password: xxxxxxxx-xxxx-xxxx
Use:
- Username:
user - Password: generated password
Base URL:
http://localhost:8080/api
POST /api/add
PUT /api/update?empId=1
DELETE /api/delete?empId=1
GET /api/get?empId=1
| Technology | Purpose |
|---|---|
| Spring Boot | Application framework |
| Spring Data JPA | Database interaction |
| Hibernate | ORM |
| MySQL | Database |
| Spring Security | Authentication |
| Lombok | Boilerplate reduction |
| Postman | API Testing |
- Clone repository
git clone https://github.com/your-username/project-name.git
- Create MySQL database
springbootdatajparestsecurity
-
Update database credentials in application.properties
-
Run the application
-
Test APIs using Postman with:
- Username: user
- Password: generated password from console
- Implemented secure REST APIs
- Integrated Spring Security with HTTP Basic
- Performed CRUD operations using Spring Data JPA
- Understood layered architecture
- Tested APIs using Postman
P. Soma Akash
Java Full Stack Trainee at Codegnan
This project demonstrates:
- Spring Boot REST API development
- Secure endpoint configuration
- MySQL database integration
- Complete CRUD functionality
Grateful to my trainer Sathya Prakash sir for invaluable guidance and support throughout my Java Full Stack training.