簡體   English   中英

.antMatchers("/swagger-ui/**").permitAll() 錯誤 405

[英].antMatchers("/swagger-ui/**").permitAll() error 405

我在 APIREST 中使用了 swagger 3,但我嘗試訪問此鏈接 http://localhost:8080/swagger-ui/,出現 405 錯誤。

這是我的 ConfigClass 中的代碼:

 protected void configure(HttpSecurity http) throws Exception {
         http
            .csrf().disable()
            .exceptionHandling()
            .authenticationEntryPoint(authenticationEntryPoint)
            .and()
            .sessionManagement()
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .authorizeRequests()
            .antMatchers(HttpMethod.GET, "/api/v1/**").permitAll()
            .antMatchers("/api/v1/auth/**").permitAll()

            .antMatchers("/swagger-ui/**").permitAll()
            .antMatchers("/swagger-resources/**").permitAll()
            .antMatchers("/swagger-ui.html").permitAll()
            .antMatchers("/webjars/**").permitAll()
            .anyRequest()
            .authenticated();
    http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
}

這是 POM.XML 中的依賴項:

     <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-boot-starter</artifactId>
        <version>3.0.0</version>
    </dependency>

有人能幫幫我嗎?

您可能正在為 GET 操作執行 PUT 調用,請檢查一次。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM