티스토리 뷰
When a bean has a single constructor, @Autowired annotation is no longer needed.
Use 'final' to make sure that object is not changed after it's initialized
However, for Setter injection, you need @Autowired.
private final UsersRepository usersRepository;
private final ModelMapper modelMapper;
//@Autowired
public UsersController(UsersRepository usersRepository, ModelMapper modelMapper){
this.usersRepository = usersRepository;
this.modelMapper = modelMapper;
}
reference
https://www.baeldung.com/constructor-injection-in-spring
http://woowabros.github.io/experience/2019/02/28/pilot-project-settle.html
'Spring Boot' 카테고리의 다른 글
Id type은 왜 Long 일까 (0) | 2019.03.10 |
---|---|
DTO(Data Transfer Object) 와 ModelMapper (0) | 2019.03.10 |
ModelMapper DTO-entity conversion (0) | 2019.03.08 |
Creating Spring Boot application with IntelliJ II (0) | 2019.02.27 |
Creating Spring Boot application with IntelliJ (0) | 2019.02.27 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- repeat()
- string class in java
- ... in Javascript
- javascript
- algorithm
- hackerrank javascript solution
- Collection Framework
- Object type casting
- HashMap
- math.abs
- 프로그래머스 알고리즘
- HackerRank Algorithm
- easy javascript algorithm
- 프로그래머스 알고리즘문제
- code refactoring
- rest parameter
- hackerrank solution
- math.max
- equals()
- 프로그래머스
- substring()
- hackerrank
- C++
- spring boot application
- easy algorithm
- hackerrank javascript
- java
- compareTo()
- 알고리즘
- Javascript Algorithm
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
글 보관함