Ошибка: не может найти символ .antmatcher ("/**")JAVA

Программисты JAVA общаются здесь
Anonymous
Ошибка: не может найти символ .antmatcher ("/**")

Сообщение Anonymous »

Я обновил свое приложение Spring Boot с версии 2.6.15 до версии 3.1.12. Но кажется, что некоторые методы были переименованы, и их позиции изменены. Например, Antmatcher () больше не существует. Я обнаружил, что есть requestMatchers () в AuthorizeHttPrequests (), но затем Access () не принимает строку. А также я не знаю, где я должен поместить oauth2resourceserver () и jwt (). < /P>
Ниже мой текущий код, который не работает, потому что Antmatcher () больше не существует: < /p>
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
@EnableWebSecurity
public class ResourceServerConfig {

@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf(AbstractHttpConfigurer::disable)
.antMatcher("/**") // web.ignoring().requestMatchers("/**/actuator/health");
}

public static class WebSecurityAccess {

@Value("${om.test.app.client-id}")
private String omTestAppClientId;

public boolean hasAccess(Authentication authentication) {
return authentication.isAuthenticated() && authentication.getPrincipal() instanceof Jwt
&& omTestAppClientId.equals(((Jwt) authentication.getPrincipal()).getClaims().get("clientId"));
}
}

}
< /code>
Как я должен решить эту проблему с Antmatcher () и Access ()? Или есть хорошие учебники?


Подробнее здесь: https://stackoverflow.com/questions/795 ... antmatcher

Вернуться в «JAVA»