Why doesn't commenting a dependency in the pom.xml (with m2eclipse) delete the jar in the tomcat server deploy directory?

泄露秘密 提交于 2019-12-24 09:18:10

问题


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


回答1:


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!




回答2:


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>



来源:https://stackoverflow.com/questions/4604316/why-doesnt-commenting-a-dependency-in-the-pom-xml-with-m2eclipse-delete-the-j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!