我设置一个春天启动的项目包括Spring数据休息和扬鞭:扬鞭不检测弹簧数据的REST API和Spring引导
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
这是我扬鞭配置:从应用
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
摘录。属性:
spring.data.rest.base-path=/api
server.context-path=/myapp
当我运行服务器时,所有休息端点都正确映射并可到达/myapp/api/...
,包括我自己创建的自定义RestController。
但是:
在
http://localhost:8080/myapp/api
我可以看到春天 数据的REST API的(JSON格式)列表中,但不能看到我的自定义RestController端点。at
http://localhost:8080/myapp/swagger-ui.html
我看到一个很好的GUI,它只列出了我的自定义RestController和错误端点,而不是Spring Data Rest API。实际上,http://localhost:8080/myapp/v2/api-docs不会引用Spring Data Rest端点,而只会引用我自定义的RestController和错误端点。
我该如何修复我的Spring Data Rest & Swagger配置?
谢谢。按照说明,我将版本升级到2.6.1并添加了Maven依赖项,但我一直处于相同的情况。 – Manu
在'.build()' – sofend