when you visit http://localhost:8080/swagger-ui.html in generating api using swagger2, the page displays:
fetching resource list: http://localhost:8080/v2/api-docs; Please wait.
returns an empty json string {} when accessing http://localhost:8080/v2/api-docs. According to the introduction, fastjson solved this problem in 1.2.15, but my version is 1.2.40, which is supposed to be no problem, but helplessness is always wrong, but I have no problem using jackson. Visit http://localhost:8080/swagger-ui.html to display documents normally.
corresponding introduction address on the Internet: solution to Swagger2 failure when SpringMVC uses FastJsonHttpMessageConverter
my main springMvc configuration file is as follows:
<mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/" />
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/" />
<mvc:annotation-driven>
<mvc:message-converters><!-- register-defaults="true"-->
<!--StringHttpMessageConverterUTF-8-->
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8"/>
</bean>
<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
<property name="fastJsonConfig" ref="fastJsonConfig"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<bean id="fastJsonConfig" class="com.alibaba.fastjson.support.config.FastJsonConfig">
<property name="charset" value="UTF-8" />
<property name="serializerFeatures">
<list>
<value>QuoteFieldNames</value>
<value>WriteMapNullValue</value>
</list>
</property>
</bean>
as above, you cannot access FastJsonHttpMessageConverter normally, but you can use jackson"s converter. The configuration is as follows:
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html; charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
and accessing the swagger-ui.html console always prompts Did not find handler method for
2017-12-28 13:45:50 DEBUG springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping.getHandlerInternal:310 - Looking up handler method for path /swagger-resources/configuration/ui
2017-12-28 13:45:50 DEBUG springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping.lookupHandlerMethod:108 - looking up handler for path: /swagger-resources/configuration/ui
2017-12-28 13:45:50 DEBUG springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping.getHandlerInternal:320 - Did not find handler method for [/swagger-resources/configuration/ui]
don"t know how to solve it, ask for help. Thank you!