Java 如何从application.properties设置springfox.documentation.swagger.v2.path

Java 如何从application.properties设置springfox.documentation.swagger.v2.path,java,swagger-2.0,Java,Swagger 2.0,我在基于Java的RESTAPI中使用了Swagger 2。API的基本路径已从application.properties文件中设置 server.contextPath=/myapi/v1/ 我可以在localhost中使用我的Swagger UI访问端点,如下URL所示: http://localhost:8080/myapi/v1/swagger-ui.html 我的终点很好。但我无法从以下URL访问JSON API文档: http://localhost:8080/myapi/v1

我在基于Java的RESTAPI中使用了Swagger 2。API的基本路径已从
application.properties
文件中设置

server.contextPath=/myapi/v1/
我可以在localhost中使用我的Swagger UI访问端点,如下URL所示:

http://localhost:8080/myapi/v1/swagger-ui.html
我的终点很好。但我无法从以下URL访问JSON API文档:

http://localhost:8080/myapi/v1/api-文件
JSON API文档如图所示:

http://localhost:8080/myapi/v1/v2/api-文件
现在显示一个额外的路径
v2
。我读过一些文章,说这是因为Swagger2默认的api文档路径,我们可以使用应用程序属性中的
springfox.documentation.swagger.v2.path
属性覆盖该路径

如何将
v2
路径设置为
http://localhost:8080/myapi/v1/api-文档
? 通过
应用程序.properties
?我一直在尝试不同的方法,但没有得到正确的结果

server.contextPath=/MyAppName/v1
springfox.documentation.swagger.v2.path=/api-docs

设置上述应用程序属性帮助我将api文档设置为正确的路径

这让我很开心,谢谢!很高兴听到这有帮助。我的下一个问题是为两个版本的服务创建swagger文档:)@VictorPetit