There are some problems in using the Knife4j(swagger enhancement) interface document

I am currently learning and developing a small project. I integrated Knife4j’s enhanced interface documentation into the project, but I encountered a problem at the moment. I will explain my problem and the dependency version information of the backend program and the frontend program in the following points.

  1. Problem
  app.c31badf5.js:1 SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at JSON.parse (<anonymous>)
    at Object.json5parse (app.c31badf5.js:1:364220)
    at r.transformResponse (app.c31badf5.js:1:196382)
    at chunk-vendors.d51cf6f8.js:2:2003275
    at Object.u [as forEach] (chunk-vendors.d51cf6f8.js:2:2005150)
    at e.exports (chunk-vendors.d51cf6f8.js:2:2003248)
    at chunk-vendors.d51cf6f8.js:2:1328322
  1. Java Program
  • Main dependencies

       <!-- SpringBoot config-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>3.3.5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

     <!-- knife4j-doc -->
            <dependency>
                <groupId>com.github.xiaoymin</groupId>
                <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
                <version>${knife4j.doc.version}</version>
            </dependency>
  • ConfigurerFile
    • application.yml
     springdoc:
       api-docs:
          path: /v3/api-docs
       swagger-ui:
          enabled: true
          path: /swagger-ui.html
          tags-sorter: alpha
      group-configs:
        - group: 'default'
          display-name: 'Test Model'
          paths-to-match: '/**'
          packages-to-scan: com.prosys.web.controller.tool
    
    • WebConfig(implements WebMvcConfigurer)
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
    
        // Add static resource mapping rules     
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/");
        //Configure the static resource request mapping address of knife4j
        registry.addResourceHandler("/doc.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
       }
    
    • SecurityConfig
    public static final String[] EXCLUDE_INTERFACE_PATHS = {"/login", "/register", "/captchaImage"};
    public static final String[] STATIC_SHADER_RESOURCES = {"/", "/*.html", "/**.html", "/**.css", "/**.js", "/profile/**"};
    public static final String[] STATIC_RESOURCES_MAPPING_PATH = {"/doc.html", "/swagger-ui.html", "/v3/api-docs/**", "/swagger-ui/**","/swagger-resources/**", "/webjars/**", "/druid/**"};
    
    protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
        return httpSecurity.authorizeHttpRequests((requests) -> {
                    permitAllUrl.getUrls().forEach(url -> requests.requestMatchers(url).permitAll());
                    // For login login registration register verification code captchaImage allow anonymous access
                    requests.requestMatchers(EXCLUDE_INTERFACE_PATHS).permitAll()
                            // Static resources, anonymous access
                            .requestMatchers(HttpMethod.GET, STATIC_SHADER_RESOURCES).permitAll()
                            .requestMatchers(STATIC_RESOURCES_MAPPING_PATH).permitAll()
                            // All requests except the above require authentication
                            .anyRequest().authenticated();
                })
    }
    
    • Knife4jDocConfig
        @Bean
        public OpenAPI customOpenApi()
        {
           return new OpenAPI().components(new Components()
            // Set the authentication request header
            .addSecuritySchemes("apikey", securityScheme()))
            .addSecurityItem(new SecurityRequirement().addList("apikey"))
            .info(getApiInfo());
        }
    
        @Bean
        public SecurityScheme securityScheme()
        {
           return new SecurityScheme()
            .type(SecurityScheme.Type.APIKEY)
            .name("Authorization")
            .in(SecurityScheme.In.HEADER)
            .scheme("Bearer");
        }
        public Info getApiInfo(){
        new Info().title("interface api")
                  .description("This is an interface document for testing the interface")
                  .contact("anshink")
                  .version("Version:1.0.0");
        }
    
  1. Web Program
Main dependency: "vue": "3.4.31",

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật