swagger3.0 sets up grouping and configures multiple scanning paths and filtering URLs

package com.jeeplus.config;

import com.fasterxml.classmate.TypeResolver;
import com.jeeplus.sys.service.dto.LightUserDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.AlternateTypeRule;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.*;


/**
 * swagger configuration
 */
@Configuration
public class SwaggerConfig implements WebMvcConfigurer {


    @Bean
    public Docket api() {//Default grouping
        TypeResolver typeResolver=new TypeResolver();//Filtering
        AlternateTypeRule alternateTypeRule=new AlternateTypeRule(typeResolver.resolve(LightUserDTO.class),typeResolver.resolve(Object.class));

        return new Docket ( DocumentationType.OAS_30 )
                //.groupName("Development Group 001")
                //resource
                .globalResponses ( HttpMethod.GET, new ArrayList <> ( ) )
                .globalResponses ( HttpMethod.PUT, new ArrayList <> ( ) )
                .globalResponses ( HttpMethod.POST, new ArrayList <> ( ) )
                .globalResponses ( HttpMethod.DELETE, new ArrayList <> ( ) )
                //Whether to start
                .enable(true)
                .alternateTypeRules(alternateTypeRule)
                //Header information
                .apiInfo ( apiInfo ( ) )
                .select ( )
                /**
                 * RequestHandlerSelectors, configure the way to scan the interface
                 * basePackage specifies the package to be scanned
                 * any() scans all, all interfaces in the project will be scanned
                 * none() does not scan
                 * withClassAnnotation() scans annotations on classes
                 * withMethodAnnotation() scans annotations on methods
                 */
                .apis(
                        RequestHandlerSelectors.basePackage ( "com.jeeplus.duxin.basicsettings.bommaintenance" )
                )
                //Add the ApiOperation annotation to the class to generate the interface document
                .apis ( RequestHandlerSelectors.withClassAnnotation ( Api.class ) )
                .apis (RequestHandlerSelectors.withMethodAnnotation (ApiOperation.class) )
                .apis ( RequestHandlerSelectors.any ( ) )
                //Filter a certain path
                .paths ( PathSelectors.any ( ) )
                .build()
                //protocol
                .protocols ( newHashSet ( "https", "http" ) )
                .securitySchemes ( securitySchemes ( ) )
                .securityContexts ( securityContexts ( ) );
    }


    /**
     * Organizational structure system management
     * @author lgn
     * @date 2023/10/25 18:20
     * @return Docket
     */
    @Bean
    public Docket api2() {
        TypeResolver typeResolver=new TypeResolver();
        AlternateTypeRule alternateTypeRule=new AlternateTypeRule(typeResolver.resolve(LightUserDTO.class),typeResolver.resolve(Object.class));

        return new Docket ( DocumentationType.OAS_30 )
                .groupName("Organizational Structure System Management")
                //resource
                .globalResponses ( HttpMethod.GET, new ArrayList <> ( ) )
                .globalResponses ( HttpMethod.PUT, new ArrayList <> ( ) )
                .globalResponses ( HttpMethod.POST, new ArrayList <> ( ) )
                .globalResponses ( HttpMethod.DELETE, new ArrayList <> ( ) )
                //Whether to start
                .enable(true)
                .alternateTypeRules(alternateTypeRule)
                //Header information
                .apiInfo ( apiInfo ( ) )
                .select ( )
                /**
                 * RequestHandlerSelectors, configure the way to scan the interface
                 * basePackage specifies the package to be scanned
                 * any() scans all, all interfaces in the project will be scanned
                 * none() does not scan
                 * withClassAnnotation() scans annotations on classes
                 * withMethodAnnotation() scans annotations on methods
                 */
/* .apis (
                        RequestHandlerSelectors.basePackage ( "com.jeeplus.duxin.basicsettings.basestamp" )
                )*/
                .apis(
                        RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financeabstract")
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financeaccountingsubject"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financecalculateproject"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financecashflow"))

                )

                //Add the ApiOperation annotation to the class to generate the interface document
                .apis ( RequestHandlerSelectors.withClassAnnotation ( Api.class ) )
                .apis (RequestHandlerSelectors.withMethodAnnotation (ApiOperation.class) )
                .apis ( RequestHandlerSelectors.any ( ) )
                //Filter a certain path
                .paths ( PathSelectors.any ( ) )
                .build()
                //protocol
                .protocols ( newHashSet ( "https", "http" ) )
                .securitySchemes ( securitySchemes ( ) )
                .securityContexts ( securityContexts ( ) );
    }


    /**
     * Financial Management
     * @author lgn
     * @date 2023/10/25 18:20
     * @return Docket
     */
    @Bean
    public Docket api3() {
        TypeResolver typeResolver=new TypeResolver();
        AlternateTypeRule alternateTypeRule=new AlternateTypeRule(typeResolver.resolve(LightUserDTO.class),typeResolver.resolve(Object.class));

        return new Docket ( DocumentationType.OAS_30 )
                .groupName("Financial Management")
                //resource
                .globalResponses ( HttpMethod.GET, new ArrayList <> ( ) )
                .globalResponses ( HttpMethod.PUT, new ArrayList <> ( ) )
                .globalResponses ( HttpMethod.POST, new ArrayList <> ( ) )
                .globalResponses ( HttpMethod.DELETE, new ArrayList <> ( ) )
                //Whether to start
                .enable(true)
                .alternateTypeRules(alternateTypeRule)
                //Header information
                .apiInfo ( apiInfo ( ) )
                .select ( )
                /**
                 * RequestHandlerSelectors, configure the way to scan the interface
                 * basePackage specifies the package to be scanned
                 * any() scans all, all interfaces in the project will be scanned
                 * none() does not scan
                 * withClassAnnotation() scans annotations on classes
                 * withMethodAnnotation() scans annotations on methods
                 */
                .apis(
                        RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financeabstract")
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financeaccountingsubject"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financecalculateproject"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financecashflow"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financecashflowcategory"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financeotherunit"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financeotherunitbookkeep"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financeotherunitbookkeepcategory"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financeregularsubject"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financestandardsubject"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financestockbookkeep"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financestockbookkeepcategory"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financesubjectappoint"))
                                .or(RequestHandlerSelectors.basePackage("com.jeeplus.duxin.basicsettings.financevoucher"))
                )

                //Add the ApiOperation annotation to the class to generate the interface document
                .apis ( RequestHandlerSelectors.withClassAnnotation ( Api.class ) )
                .apis (RequestHandlerSelectors.withMethodAnnotation (ApiOperation.class) )
                .apis ( RequestHandlerSelectors.any ( ) )
                //Filter a certain path
                .paths ( PathSelectors.any ( ) )
                .build()
                //protocol
                .protocols ( newHashSet ( "https", "http" ) )
                .securitySchemes ( securitySchemes ( ) )
                .securityContexts ( securityContexts ( ) );
    }


    /**
     * The upper part of the API page displays information
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder ( )
                .title ( "Jeeplus Microservice Interface Document" )
                .description ( "@author jeeplus" )
                .contact ( new Contact ( "jeeplus", "http://www.jeeplus.org", "[email protected]" ) )
                .version ( "9.0" )
                .build();
    }

    /**
     *Set separate authorization information for the interface
     */
    private List <SecurityScheme> securitySchemes() {
        return Collections.singletonList ( new ApiKey ( "token", "token", "header" ) );
    }

    /**
     * Global application of authorization information
     */
    private List <SecurityContext> securityContexts() {
        return Collections.singletonList (
                SecurityContext.builder()
                        .securityReferences (
                                Collections.singletonList ( new SecurityReference ( "token",
                                        new AuthorizationScope[]{new AuthorizationScope ( "global", "" )}
                                ) ) )
                        .build()
        );
    }

    @SafeVarargs
    private final <T> Set <T> newHashSet(T... ts) {
        if (ts. length > 0) {
            return new LinkedHashSet <> ( Arrays.asList ( ts ) );
        }
        return null;
    }
}



Here are the objects returned to swagger that exclude unnecessary ones:

This block is to set up multiple groups:

This block is to configure multiple scan paths: