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无法正常使用问题的更多相关文章

  1. OPGL+GLFW+GLEW配置详细步骤

    转载自:https://blog.csdn.net/weixin_40921421/article/details/80211813 本文设计的工具包: 链接:https://pan.baidu.co ...

  2. OPGL+VS2017+GLFW+GLEW配置详细步骤

    OPGL+VS2017+GLFW+GLEW配置详细步骤: https://blog.csdn.net/weixin_40921421/article/details/80211813 原博客地址:ht ...

  3. Apollo 配置详细步骤(Windows环境)

    一. 准备工作 1.下载 apollo 安装包 下载链接:http://activemq.apache.org/apollo/download.html 2.下载 JavaJDK 安装包 ( apol ...

  4. nginx 的中文配置详细解释

    文章转自:http://www.ha97.com/5194.html 更详细的模块参数请参考:http://wiki.nginx.org/Main #定义Nginx运行的用户和用户组 user www ...

  5. java的安装环境配置详细步骤

    --------------------声明,如果你有什么建议或者不懂的地方,欢迎回复,我们可以互相学习,转载请注明出处,谢谢---------------- 首先得安装jdk(Java Develo ...

  6. Oracle Stream配置详细步骤

    1 引言 Oracle Stream功能是为提高数据库的高可用性而设计的,在Oracle 9i及之前的版本这个功能被称为Advance Replication.Oracle Stream利用高级队列技 ...

  7. PERC H310 配置详细步骤【阵列RAID创建】【阵列恢复】【阵列池创建】

    机器配置: HP PRO6300 二手淘的201912,HP的主板芯片Intel Q75芯片组,集成显卡(集成显卡与H310阵列卡冲突),CPU Intel I5 3450 [raid5阵列创建] 1 ...

  8. MyEclipse新建工作空间后的配置详细步骤

    1. General --> Workspace --> UTF-8 2. General --> Editors -->File  Associations --> J ...

  9. Hadoop-HA配置详细步骤

    1. HA服务器配置 对hdfs做高可用 1.1服务器详情 服务器:centos7 Hadoop:2.6.5 Jdk:1.8 共四台服务器 192.168.1.111 node1 192.168.1. ...

随机推荐

  1. JSP+Servlet+C3P0+Mysql实现的azhuo商城

    项目简介 项目来源于:https://gitee.com/xuyizhuo/shopping 原仓库中缺失jar包及sql文件异常,现将修改过的源码上传到百度网盘上. 链接:https://pan.b ...

  2. Python第五章-内置数据结构02-列表

    Python 内置的数据结构 二.列表(list) 想一想: 前面学习的字符串可以用来存储一串信息,那么想一想,怎样存储咱们班所有同学的名字呢? 定义100个变量,每个变量存放一个学生的姓名可行吗?有 ...

  3. 医学图像dcm2d切片文件转3dnii文件

    安装 conda: conda install -c conda-forge dicom2nifti pip: pip install dicom2nifti 更新 conda: conda upda ...

  4. Spring中常用注解的介绍

    spring中使用注解时配置文件的写法: <?xml version="1.0" encoding="UTF-8"?> <span style ...

  5. Java 数组 字符 函数

    一. 1. package Hello; import java.util.Scanner; public class hello_test { public static void main(Str ...

  6. Python学习笔记:函数和变量详解

    一.面向对象:将客观世界的事物抽象成计算机中的数据结构 类:用class定义,这是当前编程的重点范式,以后会单独介绍. 二.函数编程:逻辑结构化和过程化的一种编程方法 1.函数-->用def定义 ...

  7. 快速创建Flask Restful API项目

    前言 Python必学的两大web框架之一Flask,俗称微框架.它只需要一个文件,几行代码就可以完成一个简单的http请求服务. 但是我们需要用flask来提供中型甚至大型web restful a ...

  8. 原生js判断手机端页面滚动停止

    var topValue = 0,// 上次滚动条到顶部的距离 interval = null;// 定时器 contactsList = document.getElementById(" ...

  9. Educational Codeforces Round 83 (Rated for Div. 2)

    A. Two Regular Polygons 题意:给你一个 正n边形,问你能否以这个 n 的其中一些顶点组成一个 m边形, 思路 :如果 n % m == 0 ,就可 收获:边均分 B. Bogo ...

  10. 老技术新谈,Java应用监控利器JMX(1)

    先聊聊最近比较流行的梗,来一次灵魂八问. 配钥匙师傅: 你配吗? 食堂阿姨: 你要饭吗? 算命先生: 你算什么东西? 快递小哥: 你是什么东西? 上海垃圾分拣阿姨: 你是什么垃圾? 滴滴司机: 你搞清 ...