简体   繁体   English

Eclipse WTP,maven和m2eclipse - 不复制提供的jar

[英]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). 使用Eclipse WTP和m2eclipse时,可以将所有依赖项复制到WEB-INF / lib(通过在Deployment程序集中添加“maven dependencies”)。 However, dependencies with scope "provided" are also copied, for example el-api and jsp-api. 但是,也会复制具有“提供”范围的依赖关系,例如el-api和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 你必须安装m2eclipse-wtp which is an extra plug-in for m2eclipse 这是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. 安装m2eclipse-wtp之后,只需右键单击project ---> Maven --> Update Project Configuration ,您将发现所提供范围的库不再受WTP容器的不信任。

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. 我建议安装最新版本的m2eclipse-wtp(针对Eclipse 3.6 +测试),因为它解决了以前版本中的一些主要错误。

Edit: Thanks Fred for the correction 编辑:感谢弗雷德的纠正

You need to add the Maven Library to WTP's Deployment Assembly... 您需要将Maven库添加到WTP的部署程序集......

Right click on your project, select "Properties" 右键单击您的项目,选择“属性”

From the properties menu click "Deployment Assembly" 从属性菜单中单击“部署程序集”

Click "Add" -> "Java Build Path Entries" then click "Next" 单击“添加” - >“Java构建路径条目”,然后单击“下一步”

Select "Maven Libraries" on the list and click "Finish" 在列表中选择“Maven Libraries”,然后单击“完成”

Dependencies of scope "provided" shouldn't be packaged by Maven in the final assembly. Maven在最终装配中不应打包“提供”范围的依赖关系。

However, check if you have other dependencies that are "compile" that also declare those same dependencies as "compile". 但是,请检查是否还有其他“编译”依赖项,这些依赖项也声明了与“compile”相同的依赖项。 In other words, it's very likely that el-api and jsp-api are being pulled in as transitive dependencies. 换句话说, el-apijsp-api很可能被作为传递依赖进入。

Easiest way to check is using the Dependency Hierarchy view of m2eclipse. 最简单的检查方法是使用m2eclipse的Dependency Hierarchy视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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