jar 未加载.请参阅 Servlet 规范 2.3,第 9.7.2 节.违规类:javax/servlet/Servlet.class [英] jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

查看:23
本文介绍了jar 未加载.请参阅 Servlet 规范 2.3,第 9.7.2 节.违规类:javax/servlet/Servlet.class的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个 Maven 项目,它也是一个动态 Web 项目.我在 Maven 中使用了所有 Spring 库.我创建了 web.xml,但是当我启动 Tomcat 7 服务器时,我收到以下消息:

I am running a Maven project which is also a dynamic web project. I have used all Spring libraries in Maven. I created web.xml, but when I start my Tomcat 7 server I am getting the following message:

INFO: validateJarFile(C:Usersmibvzd0workspace.metadata.plugins
org.eclipse.wst.server.core	mp2wtpwebappshapi_hl7WEB-INFlib
servlet-api-2.4.jar) - jar not loaded.
See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

我尝试从 webapp/lib 中删除 servlet,但没有成功.让我知道在我的情况下应该怎么做.

I tried deleting the servlet from webapp/lib, but it didn't work. Let me know what should be done in my case.

推荐答案

servlet API .jar 文件不能嵌入到 webapp 中,因为很明显,容器的类路径中已经有这些类:它实现了包含在这个罐子.

The servlet API .jar file must not be embedded inside the webapp since, obviously, the container already has these classes in its classpath: it implements the interfaces contained in this jar.

依赖应该在 provided 范围内,而不是默认的 compile 范围,在你的 Maven pom 中:

The dependency should be in the provided scope, rather than the default compile scope, in your Maven pom:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>

这篇关于jar 未加载.请参阅 Servlet 规范 2.3,第 9.7.2 节.违规类:javax/servlet/Servlet.class的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆