티스토리 뷰
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
- hackerrank javascript solution
- hackerrank
- ... in Javascript
- java
- 프로그래머스 알고리즘문제
- HackerRank Algorithm
- equals()
- 알고리즘
- hackerrank javascript
- compareTo()
- string class in java
- Object type casting
- easy algorithm
- math.max
- math.abs
- easy javascript algorithm
- repeat()
- spring boot application
- Javascript Algorithm
- substring()
- algorithm
- javascript
- rest parameter
- C++
- hackerrank solution
- code refactoring
- 프로그래머스
- HashMap
- Collection Framework
- 프로그래머스 알고리즘
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함