springBoot集成Swagger报错处理
时间:2023-10-16 15:07:02
作为新手菜年,在使用工具时难免会遇到各种问题springboot集成swagger在代码测试中,我遇到了以下错误,以便以后查看
错误如下:
代码跑的时候报错了To display the conditions report re-run you application with 'debug' enabled.”
这句话翻译成中文意思是:要显示条件报告,请在启用调试时重新运行应用程序。
后来看了很多大佬的文章,总结了以下解决方案。
解决方案
问题可能是由于版本配置文件的问题(2.9.x),在application.properties代码如下:
springfox.documentation.enabled=true swagger.title=spring-boot-starter-swagger swagger.description=Starter for swagger 2.x swagger.version=1.4.0.RELEASE swagger.license=Apache License, Version 2.0 swagger.licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.html swagger.termsOfServiceUrl=https://github.com/dyc87112/spring-boot-starter-swagger swagger.contact.name=didi swagger.contact.url=http://blog.didispace.com swagger.contact.email=dyc87112@qq.com swagger.base-package=com.didispace swagger.base-path=/** swagger.exclude-path=/error, /ops/** swagger.globalOperationParameters[0].name=name one swagger.globalOperationParameters[0].description=some description one swagger.globalOperationParameters[0].modelRef=string swagger.globalOperationParameters[0].parameterType=header swagger.globalOperationParameters[0].required=true swagger.globalOperationParameters[1].name=name two swagger.globalOperationParameters[1].description=some description two swagger.globalOperationParameters[1].modelRef=string swagger.globalOperationParameters[1].parameterType=body swagger.globalOperationParameters[1].required=false swagger.apply-default-response-messages=false swagger.global-response-message.get[0].code=401 swagger.global-response-message.get[0].message=401get swagger.global-response-message.get[1].code=500 swagger.global-response-message.get[1].message=500get swagger.global-response-message.get[1].modelRef=ERROR swagger.global-response-message.post[0].code=500 swagger.global-response-message.post[0].message=500post swagger.global-response-message.post[0].modelRef=ERROR spring.mvc.pathmatch.matching-strategy=ant_path_matcher
重启配置后,显示可以运行。
输入谷歌浏览器:http://localhost:8080/swagger-ui.html
显示
到这就表示配置成功了!