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

安装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也部署到服务器上。如此便可解决。


你可能感兴趣的:(spring tool suite juno 创建spring mvc 项目及遇到无法把maven依赖jar包发布到服务器下解决)