Maven dependencies not visible in WEB-INF/lib

2019-01-07 03:44发布

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 ::(

8条回答
仙女界的扛把子
2楼-- · 2019-01-07 04:04

Right-click project > Maven > Update Maven Project > OK fixed it for me

查看更多
孤傲高冷的网名
3楼-- · 2019-01-07 04:04

Check the Deployment Assembly property of the project. I have seen some mvn eclipse:eclipse generated Eclipse projects sometimes have the assets being deployed to the wrong location. From what I can remember the new Deployment Assembly had some issues with earlier versions of Eclipse 3.6 (Helios).

查看更多
甜甜的少女心
4楼-- · 2019-01-07 04:08

If you look into your deployment and see that WEB-Inf/lib is empty of your Maven dependencies, then ensuring those Maven dependencies are in your deployment assembly is crucial as mention in the chosen answer.

However be wary of Eclipse then not refreshing everything even with a Maven update. If you clean, rebuild and redeploy and still do not see the lib folder being populated try removing and re-adding the application to the server deployments via Servers>Add and Remove.

This unclogged the system for me.

查看更多
叼着烟拽天下
5楼-- · 2019-01-07 04:12

First install Maven Integration For Eclipse WTP (Help->Eclipse Marketplace)

Then in your web project's pom.xml just add:

    <packaging>war</packaging>

After that just right click the project, Maven -> Update Project, which should automagically add Maven Dependencies for you in the Deployment Assembly.

查看更多
叛逆
6楼-- · 2019-01-07 04:18

I just did maven -> update project worked for me.

查看更多
太酷不给撩
7楼-- · 2019-01-07 04:21

Right-click project -> Deployment Assembly: See if you have the Maven Dependencies and all others in there. If not, Right-Click project -> Maven -> Enable Workspace Resolution

(maybe then Maven -> Update Project, but then look again into "Deployment Assembly" and see what You've got.) this solved it (finally!) for me.

查看更多
登录 后发表回答