Junior — Middle
What Spring components and modules have you used in your projects?
sobes.tech AI
Answer from AI
In Spring projects, I used the following key components and modules:
- Spring Core — for dependency management through the IoC container and dependency injection (DI).
- Spring MVC — for building web applications using the Model-View-Controller pattern.
- Spring Data JPA — for simplifying database interactions and implementing repositories.
- Spring Boot — for rapid application development and minimal configuration.
- Spring Security — for implementing authentication and authorization.
- Spring AOP — for aspect-oriented programming, such as logging and transactions.
Example of using Spring Boot and Spring Data JPA:
@Entity
public class User {
@Id
@GeneratedValue
private Long id;
private String username;
private String email;
// getters and setters
}
public interface UserRepository extends JpaRepository<User, Long> {
User findByUsername(String username);
}
@RestController
public class UserController {
@Autowired
private UserRepository userRepository;
@GetMapping("/users/{username}")
public User getUser(@PathVariable String username) {
return userRepository.findByUsername(username);
}
}