Spring Boot 项目启动时,抛出无法访问javax.servlet.Filter找不到javax.servlet.Filter的类文件的解决方法

984 阅读1分钟

(1) 问题描述

启动 Spring Boot 项目时,抛出该问题:

双击该问题,跳转到 WebSecurityConfigurerAdapter 类:

(2) 原因分析

因为这个 WebSecurityConfigurerAdapter 类内部依赖了 spring-boot-starter-web,而我们的项目又没有引入这个包。

(3) 问题解决

在 pom.xml 中引入spring-boot-starter-web:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
 </dependency>