英文:
Spring Boot Project with Maven, can't Import WebSecurityConfigurerAdapter
问题
以下是翻译好的内容:
Trying to do User Authentication for a Spring Boot project using Maven but it wont import:
尝试在Spring Boot项目中使用Maven进行用户身份验证,但无法导入:
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; // 请注意这是原文部分,不需要翻译
It says:
它报错:
Cannot resolve symbol 'WebSecurityConfigurerAdapter'
无法解析符号 'WebSecurityConfigurerAdapter'
Here is my pom.xml file can someone tell me what I'm doing wrong.
这是我的pom.xml文件,有人能告诉我哪里错了。
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" // 请注意这是原文部分,不需要翻译
模型版本>4.0.0
属性
依赖项
构建
英文:
Trying to do User Authentication for a Spring Boot project using Maven but it wont import:
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
It says:
Cannot resolve symbol 'WebSecurityConfigurerAdapter'
Here is my pom.xml file can someone tell me what I'm doing wrong.
<?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.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ggs</groupId>
<artifactId>AT6</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AT6</name>
<description>AT6</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
# 答案1
**得分**: 1
你没有做错什么。
只是WebSecurityConfigurerAdapter已经被弃用。我建议你按照这个Spring指南来定义自己的安全配置,而不使用WebSecurityConfigurerAdapter。
https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter
英文:
You didn't do something wrong.
It's just that WebSecurityConfigurerAdapter is deprecated. I advise you to follow this spring guide to define your own security configuration without WebSecurityConfigurerAdapter.
https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论