Junior
What tasks have you solved using Spring?
sobes.tech AI
Answer from AI
Developed REST services:
- Used Spring Boot for quick setup and deployment.
- Created controllers with
@RestControllerand@GetMapping,@PostMapping, and other annotations for handling HTTP requests. - Applied Spring Data JPA to simplify database operations using repositories.
- Validated input data with
@Validand Bean Validation API annotations.
Worked with databases:
- Configured connections to PostgreSQL and MySQL using HikariCP.
- Wrote queries using JpaRepository and native SQL with Spring Data JPA.
- Implemented transactional behavior with
@Transactional.
Injected dependencies:
- Actively used Spring's IoC container for managing bean lifecycle and dependency injection via
@Autowiredand constructors.
Handled exceptions:
- Created global exception handlers with
@ControllerAdviceand@ExceptionHandler.
Worked on security:
- Integrated Spring Security for user authentication and authorization, configuring filters and access rules.
Wrote unit and integration tests:
- Used Spring Boot Test and Mockito for testing controllers, services, and repositories.
Example of using JpaRepository:
// UserRepository.java
package com.example.repository;
import com.example.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
// Spring Data JPA automatically creates implementation for this method
User findByEmail(String email);
}