在解决swagger2.9.2 报错 For input string: “” 的问题时,将swagger的 annotations以及models 替换为1.5.21版本时,依赖如下:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.22</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.22</version>
</dependency>
出现如图所示的问题,本文添加的1.5.22版本的,本文在这里添加1.5.23版本的只是举例用。
其主要原因是:把work offline勾选上了,导致依赖无法下载。
当work offline
被勾选时,maven在离线模式下工作,会从本地找相关的jar包,即使找不到相关的jar包,也不会去中央仓库下载,所以会出现Cannot resolve XXX的问题。
解决方法:
把work offline
的勾选取消后,就不会出现以上问题了,jar包也会下载下。同时也解决swagger2.9.2 报错 For input string: “” 的问题。