我目前正在关注Spring 文档和一些有关 Web 安全的教程。但现在我有一个问题,我无法调用该方法antMatchers。这是我在构建项目时遇到的错误:
java: cannot find symbol
symbol: method antMatchers(java.lang.String)
location: variable requests of type org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer<org.springframework.security.config.annotation.web.builders.HttpSecurity>.AuthorizationManagerRequestMatcherRegistry
Run Code Online (Sandbox Code Playgroud)
根据我的理解,我应该能够使用这个方法,这样我就可以允许或不允许对某个URL的HTTP请求。所以我的问题是,为什么我不能使用antMatchers()方法?
SecurityConfiguration班级:
java: cannot find symbol
symbol: method antMatchers(java.lang.String)
location: variable requests of type org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer<org.springframework.security.config.annotation.web.builders.HttpSecurity>.AuthorizationManagerRequestMatcherRegistry
Run Code Online (Sandbox Code Playgroud)
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>de.gabriel</groupId>
<artifactId>vertretungsplan</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>vertretungsplan</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency> …Run Code Online (Sandbox Code Playgroud)