如何使用eclipse + m2eclipse防止重复的servlet jar [英] How to prevent duplicate servlet jar using eclipse+m2eclipse

查看:81
本文介绍了如何使用eclipse + m2eclipse防止重复的servlet jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse + Maven + m2eclipse在Apache Tomcat中构建和测试Web应用程序.

I'm using Eclipse + Maven + m2eclipse to build and test a web application in Apache Tomcat.

我已经在Eclipse中配置了Tomcat服务器,并为我的Web应用程序配置了部署程序集,包括"Maven Dependencies"(Java构建路径条目的专业化).

I've configured a Tomcat server inside Eclipse, and configured the deployment assembly for my web app, including "Maven Dependencies" (specialization of Java Build Path Entries).

当我部署并启动服务器时,Tomcat/Catalina总是警告我:

When I deploy and start the server, Tomcat/Catalina always warns me:

信息:validateJarFile(/projects/src/main/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/webapp/WEB-INF/lib/servlet-api-2.5. jar)-未加载jar.参见Servlet Spec 2.3,第9.7.2节.令人反感的类:javax/servlet/Servlet.class

INFO: validateJarFile(/projects/src/main/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/webapp/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

这是因为m2eclipse将servlet-api-2.5视为我项目的依赖项,并将其视为"Maven Dependencies"的一部分,并将其复制为部署程序集的一部分,但是Tomcat Servlet容器具有其自己的副本这样,不喜欢在类路径上看到2个副本.

This is because m2eclipse sees servlet-api-2.5 as a dependency of my project, and considers it as part of "Maven Dependencies", and copies it as part of the deployment assembly, but the Tomcat servlet container has its own copy of this and doesn't like seeing 2 copies on the class path.

我在pom.xml中使用

标记了从项目到servlet-api-2.5的依赖关系

I've marked the dependency from my project to servlet-api-2.5 in my pom.xml with

<scope>
provided
</scope>

这确实阻止了独立的Maven将servlet-api-2.5打包到我的版本中,但是m2eclipse并不这样认为.

which does prevent standalone Maven from packaging servlet-api-2.5 into my builds, but m2eclipse doesn't see it that way.

(这没什么大不了的,因为警告是无害的,我只在IDE内的测试过程中看到它,而真正的客户看不到它,但是我仍然想知道如何解决它,因为我喜欢清洁,我喜欢了解事物的运作方式.)

(This isn't a huge deal because the warning is harmless, I only see it during testing inside the IDE, and real customers won't see it, but I'd still like to know how to fix it because I like cleanliness and I like knowing how things work.)

是否有一种正确的方法来告诉m2eclipse不要部署该文件,或者告诉Eclipse不要让m2eclipse最终确定运行时依赖关系是哪个依赖项?

Is there a correct way to tell m2eclipse not to deploy this file, or to tell Eclipse not to let m2eclipse have the final say on which dependencies are runtime dependencies?

我确实找到了 https://issues.sonatype.org/browse/MNGECLIPSE-1193提及

"Maven依赖项"容器反映了测试编译时间范围,因此应该具有范围已提供"的依赖项.

the "Maven Dependencies" container reflects test compile time scope, so it is supposed to have dependencies with scope "provided"

推荐答案

从更新站点

Install extras for m2eclipse plugin ("Maven Integration for WTP") from update site http://m2eclipse.sonatype.org/sites/m2e-extras. After install, update the project configuration.

这篇关于如何使用eclipse + m2eclipse防止重复的servlet jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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