Maven依赖关系在WEB-INF / lib中不可见 [英] Maven dependencies not visible in WEB-INF/lib
问题描述
ClassNotFoundException
,因为Maven依赖不会被复制到 WEB-INF / lib
目录。我甚至尝试在POM中添加副本依赖项部分,但没有帮助。 有人这里似乎已经解决了这个正确的方法,但我猜他忘了提及解决方案::(
这应该与eclipse和m2eclipse无关,并且可以更好地支持 - m2e-wtp 另外,你不需要复制依赖关系原因:
- 您应该调用
mvn package
(或右键单击> maven>包),并获得一个战争文件 -< packaging>
(在pom中)必须是war
- 您的依赖关系应与默认范围(如果它们是
提供
或测试
不会包含在档案中) - 如果你是将项目作为动态Web项目运行在eclipse中的服务器上,然后打开项目属性(右键单击>属性),然后选择部署程序集。点击添加,选择构建路径条目,并选择maven依赖关系。这将指示WTP将maven依赖关系发送到服务器目录。
I'm having this weird problem making my project Maven-based. I created a new Maven project in Eclipse and enabled the Dynamic Web facets. But during runtime now it throws ClassNotFoundException
because the Maven dependencies are not copied to WEB-INF/lib
directory. I even tried adding the copy-dependencies section in POM, but it didn't help.
Someone here seemed to have solved this the right way, but I guess he forgot to mention the solution ::(
This should have nothing to do with eclipse and m2eclipse, and optionally for better support - m2e-wtp. Also, you don't need copy-dependencies. Here are a few possible reasons:
- you should invoke
mvn package
(or right-click > maven > package) and obtain a war file - the<packaging>
(in the pom) must bewar
- your dependencies should be with the default scope (if they are
provided
ortest
they will not be included in the archive) - if you are running the project as dynamic web project on a server within eclipse, then you should open the project properties (right click > properties) and select "Deployment Assembly". There click "add", select "build path entries", and choose "maven dependencies". This will instruct WTP to send the maven dependencies to the server dir.
这篇关于Maven依赖关系在WEB-INF / lib中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!