-
Swagger를 Spring xml 설정을 이용하여 사용 하기설치&설정 관련/JAVA 2017. 6. 28. 09:52728x90
함께 일하는 분에게 Swagger를 소개 받고, 우리 서비스에서 사용 해보기로 하였다.
봉착한 문제는 대부분의 swagger의 설정이 SpringBoot의 Java Config기반으로 처리 하기 때문에 설정에 시간이 오래 걸릴 것이라고 걱정이 되었으나, 다음과 같이 간단한 방법으로 처리가 되었다.
Maven 설정 추가
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0</version> </dependency> <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.7.0</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml/classmate --> <dependency> <groupId>com.fasterxml</groupId> <artifactId>classmate</artifactId> <version>1.3.3</version> </dependency>
Spring servlet xml설정 추가
<bean id="swagger2Config" class="springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration"></bean> <mvc:resources location="classpath:/META-INF/resources/" mapping="swagger-ui.html"></mvc:resources> <mvc:resources location="classpath:/META-INF/resources/webjars/" mapping="/webjars/**"></mvc:resources>
이후 http://localhost:8080/swagger-ui.html으로 접속 할 경우 결과 화면을 볼 수 있다.
728x90'설치&설정 관련 > JAVA' 카테고리의 다른 글
단어 빈도수 계산기 (0) 2017.09.29 JAVA SWT를 Linux에서 실행하기 (0) 2017.04.17 [TIP] OUTLOOK 에서 첨부 파일이 "제목 없는 첨부파일 (날짜).dat" 로 표기될 때 처리 방법 (0) 2016.11.17 [TIP]메모리 관련 옵션 설정 (0) 2014.02.03 [ERROR]inconvertible types 발생시 해결 방법 (0) 2014.01.22