maven web项目导入sts_maven web 项目导入eclipse 发布时不自动拷贝依赖包到lib

当maven web项目导入Eclipse并部署时,依赖包不会自动复制到WEB-INF/lib。解决办法是在运行maven eclipse插件时添加-Dwtpversion=2.0参数,或者手动修改.classpath文件中的路径。WTP支持通过配置org.eclipse.wst.common.component文件,确保依赖正确部署。
摘要由CSDN通过智能技术生成

maven web 项目导入eclipse 发布时不自动拷贝依赖包到lweb-inf/ib问题 。

解决方案是:运行转eclipse插件式增加参数, mvn eclipse:eclipse -Dwtpversion=2.0

Problem

In Eclipse 3.5 or early version, in order to deployed the Maven dependencies to the correct “/WEB-INF/lib ” folder, you have to configure the dependencies via “Java EE Module Dependencies”, and the updated “.classpath ” file will look like following :

File : “.classpath”, by Java EE Module Dependencies…

...

sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar">

...

Since Eclipse 3.6, the “Java EE Module Dependencies” is replaced by “Web Deployment Assembly”, but you can do the same via the “Referenced Projects Classpath Entries”, however, it will update the “.classpath ” file as following :

File : “.classpath”, by Web Deployment Assembly…

...

sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar">

...

Sadly, the default (value=”../”) makes all the Maven’s dependencies failed to deploy.

Solution

Not a big issue, you still can modify the (value=”../”) to (value=”/WEB-INF/lib”) manually, but it will get override every time you run a Maven build. No worry, there are still have two solutions :

1. WTP Support

Ignore the “Referenced Projects Classpath Entries” settings, instead, make the Maven supports WTP 2.0

mvn eclipse:eclipse -Dwtpversion=2.0

It will generate a new file named “org.eclipse.wst.common.component “, under “settings ” folder, see a portion of this file :

File : “org.eclipse.wst.common.component”, by WTP

...

handle="module:/classpath/var/M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar">

uses

...

With WTP support, it helps to deploy the Maven dependencies to “/WEB-INF/lib ” folder correctly.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值