springboot集成swagger2多模块中文配置详细步骤,解决集成mybatis或mybatis-plus无法正常使用问题
pom.xm里写入swagger依赖:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
Swaggerconfig类,代码如下
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration
@EnableSwagger2
public class Swaggerconfig { @Value("${swagger2.enable}")
private boolean enable; private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("学习项目")
.description("学习项目测试工具")
.contact("Lawrence")
.version("1.0")
.build();
} @Bean("模块一")
public Docket controller1Apis() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("模块一")
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
.paths(PathSelectors.regex("/controller1.*"))
.build()
.apiInfo(apiInfo())
.enable(enable);
} @Bean("模块二")
public Docket controller2Apis() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("模块二")
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
.paths(PathSelectors.regex("/controller2.*"))
.build()
.apiInfo(apiInfo())
.enable(enable);
} } 因为使用了中文,有一些坑需要在application.yml文件里配置
server:
port: 9527
tomcat:
uri-encoding: UTF-8
max-threads: 800
min-spare-threads: 30
max-connections: 10000
servlet:
context-path: /lean spring:
http:
encoding:
charset: UTF-8
force: true
enabled: true
swagger2:
enable: true 这样多模块配置就好了,访问项目路径/swagger-ui.html就ok,效果如下

注意,如果使用mybatis-plus的情况下会出现问题。原因是启动类@ComponentScan导致swagger无法扫描到接口,改为@MapperScan就可以解决了。
springboot集成swagger2多模块中文配置详细步骤,解决集成mybatis或mybatis-plus无法正常使用问题的更多相关文章
- OPGL+GLFW+GLEW配置详细步骤
转载自:https://blog.csdn.net/weixin_40921421/article/details/80211813 本文设计的工具包: 链接:https://pan.baidu.co ...
- OPGL+VS2017+GLFW+GLEW配置详细步骤
OPGL+VS2017+GLFW+GLEW配置详细步骤: https://blog.csdn.net/weixin_40921421/article/details/80211813 原博客地址:ht ...
- Apollo 配置详细步骤(Windows环境)
一. 准备工作 1.下载 apollo 安装包 下载链接:http://activemq.apache.org/apollo/download.html 2.下载 JavaJDK 安装包 ( apol ...
- nginx 的中文配置详细解释
文章转自:http://www.ha97.com/5194.html 更详细的模块参数请参考:http://wiki.nginx.org/Main #定义Nginx运行的用户和用户组 user www ...
- java的安装环境配置详细步骤
--------------------声明,如果你有什么建议或者不懂的地方,欢迎回复,我们可以互相学习,转载请注明出处,谢谢---------------- 首先得安装jdk(Java Develo ...
- Oracle Stream配置详细步骤
1 引言 Oracle Stream功能是为提高数据库的高可用性而设计的,在Oracle 9i及之前的版本这个功能被称为Advance Replication.Oracle Stream利用高级队列技 ...
- PERC H310 配置详细步骤【阵列RAID创建】【阵列恢复】【阵列池创建】
机器配置: HP PRO6300 二手淘的201912,HP的主板芯片Intel Q75芯片组,集成显卡(集成显卡与H310阵列卡冲突),CPU Intel I5 3450 [raid5阵列创建] 1 ...
- MyEclipse新建工作空间后的配置详细步骤
1. General --> Workspace --> UTF-8 2. General --> Editors -->File Associations --> J ...
- Hadoop-HA配置详细步骤
1. HA服务器配置 对hdfs做高可用 1.1服务器详情 服务器:centos7 Hadoop:2.6.5 Jdk:1.8 共四台服务器 192.168.1.111 node1 192.168.1. ...
随机推荐
- git push错误,如何回滚
--> git push Counting objects: 81, done.Delta compression using up to 4 threads.Compressing objec ...
- 一文带你入门Java Stream流,太强了
两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:"就想看你写的啊!"你看你看,多么苍白的喜欢啊.那就&qu ...
- GO语言web框架Gin之完全指南
GO语言web框架Gin之完全指南 作为一款企业级生产力的web框架,gin的优势是显而易见的,高性能,轻量级,易用的api,以及众多的使用者,都为这个框架注入了可靠的因素.截止目前为止,github ...
- 超越Mask-RCNN:谷歌大脑的AI,自己写了个目标检测AI
这是一只AI生出的小AI. 谷歌大脑的Quoc Le团队,用神经网络架构搜索 (NAS) ,发现了一个目标检测模型.长这样: △ 看不清请把手机横过来 它的准确率和速度都超过了大前辈Mask-RCNN ...
- ios shell打包脚本 gym
#! /bin/bash project_path=$() project_config=Release output_path=~/Desktop build_scheme=YKTicketsApp ...
- MySQL默认隔离级别为什么是RR
曾多次听到“MySQL为什么选择RR为默认隔离级别”的问题,其实这是个历史遗留问题,当前以及解决,但是MySQL的各个版本沿用了原有习惯.历史版本中的问题是什么,本次就通过简单的测试来说明一下. 1. ...
- c#的全局异常捕获
以下操作在Program.cs中 1.最简单的方式try...catch.. 一般用在某一段容易出错的代码,如果用在整个软件排查,如下所示 static void Main() { try { App ...
- Html,Css遇到的bug2020031601
td,里面jquery设置height,设置成功也没有效果. div可以成功设置,并产生效果. 可能是td,div有一些隐藏的特性不同导致的.
- CentOS下的Docker离线安装
Linux下离线安装Docker 一.基础环境 1.操作系统:CentOS 7.3 2.Docker版本:18.06.1 官方下载地址(打不开可能很慢) 3.百度云Docker 18.06.1地址:h ...
- A换算时间(只想开学)HDU 6556
题目链接 思路如下 把时间转化为 24小时制下进行考虑,首先我们要明白(在24小时制下):12 点表示是下午PM ,而 24点表示的是明天的 0点(12小时制下),这两个地方需要特殊考虑 题解如下 # ...