<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
추가하면 springfox에 빨간줄로 not found 뜰 탠대 우측상단에 maven프로젝트 refresh 해주게 되면 정상적으로 반영되는 것을 볼 수 있습니다.
java/com.springboot.spring-core-guide 패키지아래에
config 패키지 생성후 SwaggerConfig 클래스파일을 생성후 아래 내용을 추가합니다
package io.seho100.server.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;
@Configuration
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
@SpringBootApplication
@EnableSwagger2
public class SpringbootCoreGuideApplication {
...
}
@EnableSwagger2 어노테이션을 추가한 후 실행시켜서
http://localhost:8080/swagger-ui/index.html로 접속해봅시다
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
resources/application.properties을 삭제 후
resources/application.yml 파일을 생성한 후에 아래 내용을 추가합니다
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher