为什么在 pom.xml 中注释依赖项(使用 m2eclipse)不会删除 tomcat 服务器部署目录中的 jar?

发布于 2024-10-10 14:43:31 字数 847 浏览 4 评论 0原文

我开始使用Maven 2.2.1并下载了最新的m2eclipse插件版本0.12.0。我使用的是 Eclipse 3.5.1 和 Tomcat 6.0.26。
我查看了 mvc-ajax 项目(在 Eclipse 中:文件>新建>项目>SVN>来自SVN的项目),当我运行服务器时,我遇到了以下异常:

org.apache.jasper.JasperException: 无法读取 TLD“META-INF/c.tld” 来自 JAR 文件 “文件:/tomcatDeployDirectory/mvc-ajax/WEB-INF/lib/jstl-1.2.jar”

需要删除jsp-api2.1.jar(正如我从其他帖子中发现的那样)。

现在我想简单地在 pom.xml 中注释 jsp-api2.1.jar 的依赖关系,我这样做了,然后 jsp-api2.1.jar 从 Maven 依赖关系中消失了。但是当我再次启动服务器时,我看到了同样的异常。我检查了tomcat服务器部署目录,又可以看到同样的jsp-api2.1.jar!我创建了一个新服务器,但我在那里看到了 jar。
这是 m2eclipse 的问题吗? eclipse maven 和 m2eclipse 的版本之间是否存在冲突?或者我应该另外设置一些东西吗?

从服务器部署目录中删除 jsp-api2.1.jar 就完成了这项工作,但是我是否总是需要手动执行此操作?

亲切的问候,
暴君

I started using Maven 2.2.1 and downloaded the latest m2eclipse plugin version 0.12.0. I am using Eclipse 3.5.1 and Tomcat 6.0.26.
I checked out the mvc-ajax project (in eclipse: File>New>Project>SVN>Project from SVN) and when I ran the server, I came upon the following exception:

org.apache.jasper.JasperException:
Unable to read TLD "META-INF/c.tld"
from JAR file
"file:/tomcatDeployDirectory/mvc-ajax/WEB-INF/lib/jstl-1.2.jar"

which required deleting the jsp-api2.1.jar (as I found out from other posts).

Now I wanted to simply comment the dependency for the jsp-api2.1.jar in the pom.xml and I did that, and the jsp-api2.1.jar vanished from the Maven Dependencies. But once I started the server again, I saw the same exception. I checked the tomcat server deployment directory and I can see the same jsp-api2.1.jar again! I created a new server, but I see the jar there.
Is this a problem with m2eclipse? Do I have some clash between the versions of eclipse maven and m2eclipse? Or should I set something additionally?

Deleting the jsp-api2.1.jar from the server deployment directory did the job, but do I need to do this manually always?

Kind Regards,
Despot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷默言语 2024-10-17 14:43:31

您应该调用mvn clean,以便您的target目录得到清理。

使用 m2eclipse,您可以通过对话框执行此操作。 右键单击pom文件>运行方式> Maven Clean

顺便说一句,对于 jsp-api 依赖项,您可以将其设置为

You should call mvn clean, so that your target dir gets cleaned-up.

With m2eclipse you do this from a dialog. Right click the pom file > Run As > Maven Clean

Btw, for the jsp-api dependency, you can set it s <provided>

眼藏柔 2024-10-17 14:43:31

我已经经历过很多次这样的事情了。通常这是因为所讨论的 JAR 是其他事物(或多个项目)的传递依赖项。

使用 Eclipse M2Eclipse POM 编辑器中的“Dependency Hierachy”视图并在右侧找到您的 JAR...然后单击它。在左侧,您将看到导致该 JAR 存在的所有依赖路径。您必须通过注释掉它们或添加“排除”节来将它们全部剪掉。

完成此操作后,您将必须重新启动 Eclipse。抱歉,但我从未见过 Eclipse 动态删除 JAR 而无需重新启动它。也许博佐关于清洁的建议可能有用,但无论如何我都会重新开始。

重新启动后,进入项目资源管理器并打开“Maven 依赖项”库并查找 JAR。如果存在,请返回并继续尝试消除 JAR,正如我上面提到的那样。如果它已从 Maven 依赖项库中消失,那么您就可以开始了。

如果它从项目特定的 Maven 依赖库中消失,但仍在部署目录中,那么您有幸向 M2Eclipse 提交错误!

I've had this happen to me a ton of times. Typically it is because the JAR in question is a transitive dependency of something else (or of multiple items).

Use the "Dependency Hierachy" view in the Eclipse M2Eclipse POM editor and find your JAR on the right hand side...then click on it. On the left hand side you will see all of the dependency paths that led to that JAR being there. You'll have to clip them all off by either commenting them out or adding an "exclude" stanza.

Once this is done, you will HAVE to restart Eclipse. Sorry, but I have never yet seen Eclipse dynamically delete a JAR without restarting it. Perhaps Bozho's tip about cleaning could work, but I'd restart anyway.

Once restarted go into the project explorer and open the "Maven Dependencies" library and look for the JAR. If it is there, go back and continue to try and eliminate the JAR as I mentioned above. If it is gone from the Maven Dependencies library, then you should be good to go.

If it is gone from the project specific Maven Dependencies library, and yet still within the deploy directory then you have the honor of filing a bug with M2Eclipse!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文