티스토리 뷰
@SpringBootConfiguration
- @Configuration과 같음. Bean을 등록하는 Java 설정파일(@Component, @Service, @Repository, @Controller, @Configuration annotation 이 붙은 method 를 @Autowired로 bean을 생성할 수 있다.)이며 @Configuration 자신도 bean으로 등록된다.
@ComponentScan
- The first stage to read Bean.
- @Component,@Configuration,@Repository,@Service,@Controller,@RestController 를 가진 Class 들을 scan해서 bean으로 등록한다.
- 다 같은 이름으로 하지 않고 저렇게 나눠놓음으로써 가독성을 높여줄 수 있다.
- 같은 package에 등록이 되어있어야 bean을 생성할 수 있다.
@EnableAutoConfiguration
- The second stage to read Bean
- @ComponentScan 이 읽어들어온 bean을 다시 등록.
@SpringBootApplication
위의 3가지 annotation을 합친 것 과 같은 기능을 한다.
@Controller
- @Controller 에서만 @RequestMapping 사용가능. @ResponseBody 따로 명시해야함
@RestController
- @ResponseBody 자동적용
@RequestBody
- 요청이 온 data(JSON or XML) 를 Java객체로 mapping 해주는 annotation
@ResponseBody
- Java객체를 http응답객체로 전송할 수 있다.
- @RestController 에는 default로 설정이 되어있기때문에 생략가능하다.
@RequestMapping
- 요청 URL을 어떤 method가 처리할지 mapping해주는 annotation. @Controller 에서 사용.
- e.g. @RequestMapping"/api/users" -> 어디로 mapping을 요청 할 것인지 작성해준다.
- GET method by default. to map to other HTTP methods, you have to specify it.
- class-level
@GetMapping
- @RequestMapping(Method=RequestMethod.GET)의 축약형
- method-level
@Repository
- Data 저장소
@Service
- Business logic
@Resource
- @Autowired 같이 객체를 주입해준다. 그러나, Resource는 이름이 같은 것을 기준으로 Bean을 주입해준다.
@PathVariable
- 주소에 적히는 값
- method parameter 앞에 쓰인다
- e.g. "/{id}" 의 id가 @PathVariable String id 의 'id' 와 연결해주는 annotation
@RequestParam
- @PathVariable 과 사용법이 비슷하지만 주소가 아닌 요청에 담기는 값을 지칭한다.
'Spring Boot' 카테고리의 다른 글
Creating Spring Boot application with IntelliJ II (0) | 2019.02.27 |
---|---|
Creating Spring Boot application with IntelliJ (0) | 2019.02.27 |
@RestController (0) | 2019.02.10 |
Dependency Injection (0) | 2019.01.30 |
객체주입 annotation 의 차이 (0) | 2019.01.05 |
- Total
- Today
- Yesterday
- 프로그래머스 알고리즘문제
- spring boot application
- string class in java
- repeat()
- algorithm
- rest parameter
- math.max
- HackerRank Algorithm
- 알고리즘
- easy algorithm
- compareTo()
- C++
- substring()
- Collection Framework
- hackerrank javascript solution
- code refactoring
- HashMap
- hackerrank solution
- ... in Javascript
- Object type casting
- javascript
- hackerrank javascript
- equals()
- java
- 프로그래머스
- math.abs
- hackerrank
- easy javascript algorithm
- 프로그래머스 알고리즘
- 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 | 31 |