simDev1234
심플하고 차분하게
simDev1234
전체 방문자
오늘
어제
  • 분류 전체보기
    • Computer Science
      • Basic Math
      • Data Structure
      • Algorithm
      • Database
      • OS
    • Language
      • Java
      • Kotlin
      • SQL
    • Framework
      • Spring
      • Orm&Mapper
      • 프로젝트로 스프링 이해하기
      • 스프링 라이브러리
    • Infra
      • Cloud
      • Docker
      • Redis
      • AWS, Azure
      • Device
    • Etc
      • CleanCoding
    • Git,Github

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 스프링
  • scanner #next() #nextLine()
  • 자바메모리구조
  • JVM메모리구조
  • null
  • 자바
  • controllerTest
  • 참조타입
  • 컨트롤러
  • 참조변수
  • 자바프로그램
  • 404
  • 자바프로그래밍

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
simDev1234

심플하고 차분하게

[이커머스 프로젝트] Swagger2 적용
Framework/프로젝트로 스프링 이해하기

[이커머스 프로젝트] Swagger2 적용

2022. 11. 25. 15:22

|  Swagger2 적용하기

 

[1] 의존성 주입

implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'

 

[2] Swagger2 UI 환경 파일 추가

package com.zerobase.cms.user.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket swagger(){
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

}

 

[3] Controller 를 작성한다.

- Controller 작성시 @ApiOperation 어노테이션을 사용해 API 주석을 단다.

@RestController
@RequiredArgsConstructor
public class TestController {

    private final EmailSendService emailSendService;

    @GetMapping
    @ApiOperation(value = "이메일 전송 테스트 API", notes="이메일 전송 테스트")
    public Response sendTestEmail(){
        return emailSendService.sendEmail();
    }

}

 

[4] 마지막으로 application을 실행한 후,  브라우저에서 확인

http://localhost:8080/swagger-ui.html

 

 

[ 출처 ]

https://sharplee7.tistory.com/48

https://kim-jong-hyun.tistory.com/49

'Framework > 프로젝트로 스프링 이해하기' 카테고리의 다른 글

[이커머스 프로젝트] QueryDSL를 통해 상품 검색하기  (0) 2022.12.13
[이커머스 프로젝트] 이메일 전송 기능 구현 (Mailgun, Feign)  (0) 2022.11.25
[이커머스 프로젝트] 멀티 모듈 생성하기  (0) 2022.11.25
[이커머스 프로젝트] API Gateway를 활용한 MSA (Micro Service Architecture)  (0) 2022.11.25
[이커머스 프로젝트] 환경 변수를 외부에서 주입하는 법  (0) 2022.11.25
    'Framework/프로젝트로 스프링 이해하기' 카테고리의 다른 글
    • [이커머스 프로젝트] QueryDSL를 통해 상품 검색하기
    • [이커머스 프로젝트] 이메일 전송 기능 구현 (Mailgun, Feign)
    • [이커머스 프로젝트] 멀티 모듈 생성하기
    • [이커머스 프로젝트] API Gateway를 활용한 MSA (Micro Service Architecture)
    simDev1234
    simDev1234
    TIL용 블로그. * 저작권 이슈가 있는 부분이 있다면 댓글 부탁드립니다.

    티스토리툴바