Spring Boot项目使用Maven,无法导入WebSecurityConfigurerAdapter。

huangapple go评论50阅读模式
英文:

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
模型版本>4.0.0

父级
org.springframework.boot
spring-boot-starter-parent
3.0.5

com.ggs
AT6
0.0.1-SNAPSHOT
AT6
AT6
属性
17


依赖项


org.springframework.boot
spring-boot-starter-security


org.springframework.boot
spring-boot-starter-thymeleaf


org.springframework.boot
spring-boot-starter-web


org.thymeleaf.extras
thymeleaf-extras-springsecurity6


org.springframework.boot
spring-boot-devtools
runtimetrue


com.mysql
mysql-connector-j
runtime


org.springframework.boot
spring-boot-starter-test
test


org.springframework.security
spring-security-test
test


构建

插件

org.springframework.boot
spring-boot-maven-plugin
// 请注意这是原文部分,不需要翻译

英文:

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

huangapple
  • 本文由 发表于 2023年4月11日 01:06:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979096.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定