使用JRebel启动应用时, swagger报错Version must not be null o empty!
java.lang.IllegalArgumentException: Version must not be null o empty!
at org.springframework.util.Assert.hasText(Assert.java:289) ~[spring-core-5.3.31.jar:5.3.31]
at springfox.documentation.common.Version.parse(Version.java:92) ~[springfox-core-2.10.5.jar:null]
at springfox.documentation.common.SpringVersion.getVersion(SpringVersion.java:34) ~[springfox-core-2.10.5.jar:null]
at springfox.documentation.swagger.common.XForwardPrefixPathAdjuster.adjustedPath(XForwardPrefixPathAdjuster.java:49) ~[springfox-swagger-common-2.10.5.jar:null]
at springfox.documentation.swagger.common.HostNameProvider.fromServletMapping(HostNameProvider.java:66) ~[springfox-swagger-common-2.10.5.jar:null]
at springfox.documentation.swagger.common.HostNameProvider.componentsFrom(HostNameProvider.java:42) ~[springfox-swagger-common-2.10.5.jar:null]
at springfox.documentation.swagger2.web.Swagger2ControllerWebMvc.getDocumentation(Swagger2ControllerWebMvc.java:101) ~[springfox-swagger2-2.10.5.jar:null]
......
触发代码springfox.documentation.swagger.common.XForwardPrefixPathAdjuster#adjustedPath
@Override
public String adjustedPath(String path) {
String prefix = request.getHeader(X_FORWARDED_PREFIX);
if (prefix != null) {
prefix = isEmpty(prefix) ? "/" : prefix;
if (!supportsXForwardPrefixHeader(springVersion.getVersion())) {
return prefix + path;
} else {
return prefix;
}
} else {
return path;
}
}
springVersion.getVersion()处, 其内部调用org.springframework.core.SpringVersion.getVersion(), 在使用JRebel会返回null, 导致校验失败.
另外在查阅资料时, 了解到使用JRebel还可能会导致swagger的接口文档取不到带泛型的Bean取不到泛型类内部信息.