spring tool suite juno 创建spring mvc 项目及遇到无法把maven依赖jar包发布到服务器下解决

本文介绍了如何在Eclipse 4.2上安装Spring Tool Suite,并详细阐述了利用STS创建Spring MVC项目的过程。在部署项目到Tomcat服务器时遇到了`ClassNotFoundException`,原因是maven依赖的jar包未能发布到服务器。通过查阅资料,找到了问题解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装spring tool suite 在eclipse4.2上:

打开“Help"-->"Eclipse Marketplace" --> 搜索 STS --> 选择 Spring Tool Suite For 3.8,4.2-->按照提示安装即可。楼主已经安装通过。

使用spring tool suite 创建spring mvc 项目:

请参考:http://www.itnose.net/detail/6076489.html;

在按照上面博客里操作后,在发布项目到tomcat上时,启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoader。

查看服务器上的部署文件时,发现服务器WEB-INF下有classes、resources等文件,唯独没有lib包,说明maven依赖包没有发布到服务器上。通过stackoverflow上的一篇文章也有人遇到相同的问题,地址如下:
http://stackoverflow.com/questions/6322711/tomcat-spring-web-class-not-found-exception-org-springframework-web-context

解决方案:

The solution was simple. Right Click on your web project in Project Explorer -> select 'Properties'. Under project properties, select 'Deployment Assembly'.

The Deployment Assembly property page shows the content that will be published as a assembled artifact by Eclipse to the server. You need to tell Eclipse that you want all your Maven dependencies to be published too.

To do that, click 'Add' button, then select 'Java Build Path Entries'. Click Next and select Maven Dependencies. This will publish the Maven dependency JAR files to the lib folder when Eclipse publishes your project to WST server.

This approach worked for me.

意思是通过右键项目->Deployment Assemly->Add->Java Build Path Entries-> 选择Maven Dependencies。告诉项目在部署的时候把把Java Build 下的Maven Dependencies也部署到服务器上。如此便可解决。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值