代码之家  ›  专栏  ›  技术社区  ›  Andres Ramirez

.antMatchers(“/招摇过市ui/**”)。permitAll()错误405

  •  0
  • Andres Ramirez  · 技术社区  · 2 年前

    我正在我的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>
    

    有人能帮我吗?

    1 回复  |  直到 2 年前
        1
  •  0
  •   Srinivas    2 年前

    您可能正在执行GET操作的PUT调用,请检查一次。