首页 > 其他分享 >【WEEK14】 【DAY5】Swagger Part 3【English Version】

【WEEK14】 【DAY5】Swagger Part 3【English Version】

时间:2024-06-02 17:31:34浏览次数:23  
标签:return WEEK14 DAY5 annotations Part import Swagger Docket public

2024.5.31 Friday
Following up on【WEEK14】 【DAY4】Swagger Part 2【English Version】

Contents

16.6. Configure API Groups

16.6.1. Modify SwaggerConfig.java

package com.P47.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration  // Equivalent to @Component
@EnableSwagger2 // Enable Swagger2
public class SwaggerConfig {
    // Configure the bean instance Docket for Swagger, to set specific parameters for Swagger
    @Bean
    public Docket docket(Environment environment){

        // Set the environments where Swagger should be displayed
        Profiles profiles = Profiles.of("dev", "test");
        // Determine if the current environment matches the profiles
        // Use enable() to accept this parameter and decide whether to display
        boolean flag = environment.acceptsProfiles(profiles);
        flag=true;  // To access through port 8080, and because the dev and test profile ports do not include 8080, manually set flag to true to ensure enable(flag) starts normally.

        return new Docket(DocumentationType.SWAGGER_2)  // See the source code in DocumentationType.classpublic class DocumentationType extends SimplePluginMetadata method, select the appropriate version for editing
                .apiInfo(apiInfo()) // Public Docket(DocumentationType documentationType) method, click on ApiInfo to go to ApiInfo.class
                .enable(flag)  // Whether to enable Swagger, if false it cannot be started, and the page shows: 

标签:return,WEEK14,DAY5,annotations,Part,import,Swagger,Docket,public
From: https://blog.csdn.net/2401_83329143/article/details/139350056

相关文章

  • 【WEEK14】 【DAY2】Shiro第七部分【中文版】
    2024.5.28Tuesday接上文【WEEK14】【DAY1】Shiro第六部分【中文版】目录15.8.Shiro整合Thymeleaf15.8.1.修改pom.xml添加依赖15.8.1.1.shiro-thymeleaf整合包导入15.8.1.2.当前完整的pom文件15.8.2.修改ShiroConfig.java15.8.3.修改index.html15.8.4.给root用户开放......
  • 【WEEK14】 【DAY3】Swagger Part 1【English Version】
    2024.5.29WednesdayContents16.Swagger16.1.IntroductiontoSwagger16.1.1.Front-EndandBack-EndSeparation16.1.2.TheEraofFront-EndandBack-EndSeparation16.1.3.IssuesArising16.1.4.Solution16.1.5.Swagger16.2.IntegratingSwaggerintoSpringBoot1......
  • Part 3.1 深度优先搜索
    深度优先搜索(DFS),即按照深度优先的顺序搜索的算法。深度优先搜索一般使用栈来实现。[USACO1.5]八皇后CheckerChallenge题目描述一个如下的6×6......
  • 【WEEK14】 【DAY5】Swagger第三部分【中文版】
    2024.5.31Friday接上文【WEEK14】【DAY4】Swagger第二部分【中文版】目录16.6.配置API分组16.6.1.修改SwaggerConfig.java16.6.2.重启16.7.实体配置16.7.1.新建pojo文件夹16.7.2.修改HelloController.java16.7.3.重启16.8.常用注解16.8.1.Swagger的所有注解定义在i......
  • 60天【代码随想录算法训练营34期】第十章 单调栈part03 (84.柱状图中最大的矩形)
    84.柱状图中最大的矩形classSolution:deflargestRectangleArea(self,heights:List[int])->int:s=[0]result=0heights.insert(0,0)heights.append(0)foriinrange(1,len(height......
  • 【Unity2D 2022:Particle System】添加粒子特效
    一、创建粒子系统游戏物体1. 创建粒子系统游戏物体SmogEffect 2.给粒子特效添加精灵贴图    (1)启用TextureSheetAnimation(纹理表动画)    (2)点击加号添加一个纹理,并将两张厌恶图片导入到纹理中3.设置两张图片随机播放(防止烟雾粒子变化)   ......
  • 代码随想录算法训练营Day55 | 583. 两个字符串的删除操作、72. 编辑距离、编辑距离总
    本文目录583.两个字符串的删除操作做题看文章72.编辑距离做题看文章编辑距离总结篇以往忽略的知识点小结个人体会583.两个字符串的删除操作代码随想录:583.两个字符串的删除操作Leetcode:583.两个字符串的删除操作做题找出最长公共子序列,然后用两个字符串的......
  • GEE 27 高级栅格可视化 Advanced Raster Visualization(Part6)
    Overview ThischaptershouldhelpusersofEarthEnginetobetterunderstandrasterdatabyapplyingvisualizationalgorithmssuchashillshading,hillshadows,andcustomcolormaps.Wewillalsolearnhowimagecollectiondatasetscanbeexploredbyani......
  • 【WEEK14】 【DAY2】Shiro Part 7【English Version】
    2024.5.28TuesdayContinuationfromprevious【WEEK14】【DAY1】ShiroPart6【EnglishVersion】Contents15.8.IntegrateShirowithThymeleaf15.8.1.Modifypom.xmltoAddDependencies15.8.1.1.Importingtheshiro-thymeleafIntegrationPackage15.8.1.2.......
  • Particles.js:为Web项目增添动态粒子效果
    Particles.js:为Web项目增添动态粒子效果示例介绍Particles.js是一个轻量级的JavaScript库,用于在Web页面上创建和管理动态粒子效果。它允许开发者通过简单的配置文件实现复杂的动画效果,为网页增添视觉吸引力。粒子可以是点、线、图像等,能够根据用户交互进行动态变化,Particles.......