简体   繁体   中英

Eclipse WTP, maven and m2eclipse - not copying provided jars

When using Eclipse WTP and m2eclipse it is possible to copy all dependencies to WEB-INF/lib (by adding "maven dependencies" in the Deployment assembly). However, dependencies with scope "provided" are also copied, for example el-api and jsp-api. That disturbs the container and it fails to start.

Any solution for not copying the "provided" jars?

You have to install the m2eclipse-wtp which is an extra plug-in for m2eclipse .It will do this job for you. After installing the m2eclipse-wtp , just right-click project ---> Maven --> Update Project Configuration , you will find that the libs of the provided scope will not be distrusted to the WTP container anymore.

See this for the installation instruction. I would suggest to install the latest version of m2eclipse-wtp (tested against Eclipse 3.6 +) as it solves some major bugs in the previous versions.

Edit: Thanks Fred for the correction

You need to add the Maven Library to WTP's Deployment Assembly...

Right click on your project, select "Properties"

From the properties menu click "Deployment Assembly"

Click "Add" -> "Java Build Path Entries" then click "Next"

Select "Maven Libraries" on the list and click "Finish"

Dependencies of scope "provided" shouldn't be packaged by Maven in the final assembly.

However, check if you have other dependencies that are "compile" that also declare those same dependencies as "compile". In other words, it's very likely that el-api and jsp-api are being pulled in as transitive dependencies.

Easiest way to check is using the Dependency Hierarchy view of m2eclipse.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM