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. 动态规划-区间dp-Palindrome Removal

    2019-11-09 10:31:09 问题描述: 问题求解: n = 100,典型的O(n ^ 3)的动规问题.一般来说这种O(n ^ 3)的问题可以考虑使用区间dp来解决. 区间dp是典型的三层结 ...

  2. 决战Leetcode: easy part(1-50)

    本博客是个人原创的针对leetcode上的problem的解法,所有solution都基本通过了leetcode的官方Judging,个别未通过的例外情况会在相应部分作特别说明. 欢迎互相交流! em ...

  3. 在Fedora中安装OpenCV-Python | 二

    目标 在本教程中 我们将学习在你的Fedora系统中设置OpenCV-Python.针对Fedora 18(64位)和Fedora 19(32位)进行以下步骤. 介绍 可以通过两种方式在Fedora中 ...

  4. python中面向对象&装饰器

    类的定义 基本形式: class ClassName(object): Statement 1.class定义类的关键字 2.ClassName类名,类名的每个单词的首字母大写. 3.object是父 ...

  5. CDN 内容分发

    1,传统架构访问服务器资源: www.aiyuesheng.com/page/logo.png 这是部署在服务器上的一张图片,因为服务器部署在上海,所以在上海或周边的人访问要稍微快一点,但是,若是云南 ...

  6. Python python 五种数据类型--字典

    # 定义一个字典 var1 = {'a':20,'b':40}; var2 = dict(); print(type(var1)) print(type(var2)) # 长度 length = le ...

  7. [bzoj]1053反质数<暴搜>

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1053 感想:这道题拿到以后还是想去知道一个数的约数个数要怎么求,去网上搜了公式,但是还是没有思 ...

  8. linux中的bash

    一.bash的简介 操作系统都是需要通过shell跟内核来交互的,常见的shell有GUI.KDE.sh.csh.bash.tsh.zsh等. 而linux中最常用的shell就是bash. 二.ba ...

  9. Pycharm 文件模板配置

    Pycharm 模板配置 #!/usr/bin/python # -*- coding: UTF-8 -*- # Author:${USER} 作者 # FileName:${NAME} 文件名称 # ...

  10. 一款基于SVM算法的分布式法律助手

    一. 项目简介 与 使用说明 体验网站(适配手机端): http://www.zhuchangwu.com 项目基于 Spring Cloud .Vue 构建,平台针对需要维权的用户而设计,主要提供如 ...