Eclipse WTP、maven和m2eclipse——没有复制提供的jar

时间:2023-01-25 11:02:03

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.

使用Eclipse WTP和m2eclipse时,可以将所有依赖项复制到WEB-INF/lib(通过在部署程序集中添加“maven依赖项”)。但是,与“提供”范围的依赖关系也被复制,例如el-api和jsp-api。这扰乱了容器,它无法启动。

Any solution for not copying the "provided" jars?

对于不复制“提供”的jar,有什么解决方案吗?

3 个解决方案

#1


14  

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.

您必须安装m2eclipse-wtp,这是m2eclipse的额外插件,它将为您完成这项工作。在安装了m2eclipse-wtp之后,只需右键单击项目—> Maven—>更新项目配置,您将发现所提供范围的libs将不再信任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 +进行测试),因为它解决了以前版本中的一些主要bug。

Edit: Thanks Fred for the correction

编辑:谢谢弗雷德的更正

#2


2  

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

您需要将Maven库添加到WTP的部署程序集中……

Right click on your project, select "Properties"

右键单击项目,选择“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库”并单击“Finish”

#3


1  

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". In other words, it's very likely that el-api and jsp-api are being pulled in as transitive dependencies.

但是,请检查您是否有其他的“编译”依赖项,它们也声明与“编译”相同的依赖项。换句话说,el-api和jsp-api很可能被作为传递性依赖项引入。

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

最简单的检查方法是使用m2eclipse的依赖层次结构视图。

#1


14  

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.

您必须安装m2eclipse-wtp,这是m2eclipse的额外插件,它将为您完成这项工作。在安装了m2eclipse-wtp之后,只需右键单击项目—> Maven—>更新项目配置,您将发现所提供范围的libs将不再信任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 +进行测试),因为它解决了以前版本中的一些主要bug。

Edit: Thanks Fred for the correction

编辑:谢谢弗雷德的更正

#2


2  

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

您需要将Maven库添加到WTP的部署程序集中……

Right click on your project, select "Properties"

右键单击项目,选择“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库”并单击“Finish”

#3


1  

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". In other words, it's very likely that el-api and jsp-api are being pulled in as transitive dependencies.

但是,请检查您是否有其他的“编译”依赖项,它们也声明与“编译”相同的依赖项。换句话说,el-api和jsp-api很可能被作为传递性依赖项引入。

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

最简单的检查方法是使用m2eclipse的依赖层次结构视图。