@Service
서비스 계층에서 사용되는 클래스임을 알림
public class UserService {
@Autowired
private UserRepository userRepository;
public User getUserById(Long id) {
return userRepository.findById(id).orElse(null);
}
public User saveUser(User user) {
return userRepository.save(user);
}
}
https://standout.tistory.com/477
Annotation - @Autowired @Qualifier
@Autowired 메서드 파라미터에 맞는 타입의 빈을 찾아서 자동으로 주입 의존성 주입(Dependency Injection)을 자동화하는 데 사용되는 어노테이션 속성(field), setter method, constructor(생성자)에서 사용된다. @
standout.tistory.com
'JAVA > Spring' 카테고리의 다른 글
Annotation - @Configuration (0) | 2023.04.20 |
---|---|
Annotation - @Repository (0) | 2023.04.19 |
Annotation - @PostMapping (0) | 2023.04.19 |
Annotation - @GetMapping (0) | 2023.04.19 |
Annotation - @RequestMapping (0) | 2023.04.19 |