我設置一個春天啓動的項目包括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