本文介绍了Jar文件无法在tomcat webapps中加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我尝试将maven项目部署到tomcat时遇到的错误
mvn tomcat7:deploy
错误:
INFO:validateJarFile (D:\ Softwares \ tomcat \apache-tomcat-7.0.50 \webapps \ myWebApp_
1 \ WEB-INF \lib \ javax.servlet-api-3.0.1.jar ) - 罐子没装。请参阅Servlet规范3.
0,第10.7.2节。违规类:javax / servlet / Servlet.class

This is what the error i got when i try to deploy maven project to tomcatmvn tomcat7:deployError : INFO: validateJarFile(D:\Softwares\tomcat\apache-tomcat-7.0.50\webapps\myWebApp_1\WEB-INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class

但是WEB-INF中没有javax.servlet-api-3.0.1.jar lib
谢谢

But the javax.servlet-api-3.0.1.jar is there in WEB-INF\libThanks

推荐答案

Servlet3.0已经在其lib文件夹中附带了tomcat,默认情况下,tomcat将始终加载那里存在的servlet jar。这就是为什么你得到tomcat没有在你的项目中加载jar的警告。

Servlet3.0 is already shipped with the tomcat inside its lib folder and by default tomcat will always load the servlet jar present there. Thats why you are getting the warning that tomcat is not loading your jar inside the project.

简单的解决方案:如果您使用的是maven,请在pom.xml中将其范围设置为提供并且maven将不要将它放在项目的WEB-INF / lib中。类似

Simple solution : If you are using maven, set its scope as provided inside the pom.xml and maven will not place it in the WEB-INF/lib of your project. Something like

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

这篇关于Jar文件无法在tomcat webapps中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 15:12