一、问题描述
在Srping Boot中集成了SwaggerUI作为接口文档工具,然后创建了多个组,使用了中文,一运行就提示:
Can't read swagger JSON from http://localhost:8080/v2/api-docs?group=基础模块
查看控制台输出,发现是由于中文乱码导致的:
二、解决方法
由于这里用的是SpringBoot,而SpringBoot内嵌了Tomcat,所以的话,需要做如下配置:
# Tomcat
server:
tomcat:
uri-encoding: UTF-8
max-threads: 1000
min-spare-threads: 30
uri-encoding: UTF-8
spring:
http:
encoding:
charset: UTF-8
force: true
enabled: true