반응형

Spring 13

Swagger 라이브러리 사용하기(API 명세서 자동화)

Swagger 란? 프로젝트 내의 API 명세서를 자동으로 만들어 HTML 화면으로 보여주는 라이브러리이다. 설정방법 1. pom.xml 또는 build.gradle 에 라이브러리 추가 io.springfox springfox-swagger2 2.9.2 io.springfox springfox-swagger-ui 2.9.2 // https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2' // https://mvnrepository.com/artifact/io.springfox/springfox-sw..

스프링 2022.08.18

@RestController와 @RequestMapping

@RestController - 스프링 프레임워크 4 버전 부터 사용가능한 어노테이션 - @Controller + @ResponseBody - 문자열과 REST Data(JSON/XML)을 전송할 수 있음 - View를 거치지 않고 HTTP ResponseBody에 직접 Return 값을 담아서 보냄 @RequestMapping - MVC 핸들러 매핑을 위하여 사용 - 컨트롤러의 메서드와 RequestMapping으로 URL 매핑하여 경로 설정 - Value: "{URL}", method: GET, POST, DELETE, PUT, PATCH - 스프링 프레임워크 4.3 버전 부터는 메서드 지정 방식보다 간단한 아래 어노테이션 사용 @GetMapping, @PostMapping, @DeleteMappin..

스프링 2022.08.17

[Spring] 스프링부트 스케줄러 사용하기

1. @SpringBootApplication 이 선언된 패키지에 @EnableScheduling 애노테이션을 선언한다. * @EnableScheduling 은 @SpringBootApplication 이 선언된 패키지 또는 하위 패키지에 붙여야 함. @SpringBootApplication @EnableScheduling public class SchedulerApplication{ public static void main(String[] args){ SpringApplication.run(SchedulerApplication.class, args); } } 2. 스케줄러를 구현할 class에 @Component 애노테이션을 선언한다. 3. 스케줄러가 되는 메서드에 @Scheduled 애노테이션을 선..

스프링 2022.03.29
반응형