You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring项目WAR包控制台启动时缺失jakarta.servlet.Filter类的问题求助

Spring项目WAR包控制台启动时缺失jakarta.servlet.Filter类的问题求助

大家好,我碰到个棘手的问题想请教下各位:

我用IntelliJ IDEA开发了一个基于Spring框架的项目,在IDE里正常启动运行完全没问题。之后我把项目打包成了WAR包,然后在WAR文件所在目录执行了下面的启动命令:

java -classpath "lib/*:classes/." com.example.onlinetesting.OnlineTestingApplication

命令执行后项目尝试启动,但控制台抛出了找不到类的错误,具体栈信息如下:

Caused by: java.io.FileNotFoundException: class path resource [jakarta/servlet/Filter.class] cannot be opened because it does not exist
        at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:215)
        at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:54)

我的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">

(注:原提问中pom.xml内容未粘贴完整,以上为已提供的部分)

麻烦各位帮忙分析下这是什么原因导致的,应该怎么解决呢?

备注:内容来源于stack exchange,提问作者Strelka M

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 11:04:36