我删除了@ EnableSwagger2& io.springfox:springfox-swagger2依赖,以便不使用传统的swagger相关注释,而是使用JSON文件。
我已使用此处分享的详细信息将Swagger从基于JSON的注释更改为:Overcoming Swagger Annotation Overload by Switching to JSON
有人可以帮我解决可能导致问题的原因吗?
答案 0 :(得分:0)
我认为您尚未在Pom.xml文件中添加swagger依赖项:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.5.0</version>
</dependency>
我认为这可能是因为它没有打开Swagger UI。 请尝试在配置文件中创建bean,以便swagger可以正常运行它。
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.cloud")))
.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.data.rest.webmvc")))
.paths(PathSelectors.any()).build();
}}