How to prevent duplicate servlet jar using eclipse+m2eclipse

前端 未结 5 584
说谎
说谎 2020-12-15 22:38

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

I\'ve configured a Tomcat server inside Eclipse, and configured the depl

5条回答
  •  感动是毒
    2020-12-15 23:13

    I have just had a similar problem, and believe I have got to the bottom of it.

    If you go to your server configuration settings in Eclipse and select "Serve Modules without Publishing" then this should no longer occur.

    Maven/M2Eclipse is building the WAR correctly - servlet-api-2.5.jar wont be in your target directories or WAR file.

    But the problem is, when you deploy the application via eclipse on to your tomcat, Eclipse does not use your maven built WAR/target directories as default, it just uses the normal Eclipse "export" settings for your project. So it sees in your "Java EE Modules" (or "Deployment Assembly List" if you are using Helios) the list of all the jars in your Maven_Dependencies, but it does not respect the scope, and just deploys all the jars.

    If you select serve without publishing option then Eclipst/Tomcat should just run the app straight off your target directory so will respect the maven scopes.

    It won't ever affect your live deployments (unless you are deploying via eclipse!) as maven is doing the right thing, but it can sometimes cause problems locally as you can ave conflicting servlet/jsp jars which can cause classcastexceptions and general misery...

提交回复
热议问题