Spring MVC 应用程序的构建错误
我对 Spring 框架相当陌生。我最近安装了 SpringSource Tool Suite(版本 2.8.1.RELEASE)。使用 Subclipse,我查看了我的队友创建的 Spring MVC 项目。它在他的机器上运行良好,但我们无法弄清楚为什么在我的机器上发生构建错误。
我使用 Tomcat v6.0 Server 来运行该项目。这是错误的一部分:
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
2012-jan-30 13:43:46 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:926)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
Tomcat 服务器具有以下类路径:引导条目:JRSE 系统库 [jdk1.6.0_27]、spring-2.5.2-20080220-410.jar。用户条目:bootstrap.jar、tools.jar
关于如何解决此问题有什么想法吗?
I'm fairly new to the Spring framework. I have recently installed SpringSource Tool Suite (version 2.8.1.RELEASE). Using Subclipse, I have checked out a Spring MVC project that my team mate has created. It works fine on his machine, but we can't figure out why a build error is happening on my machine.
I use Tomcat v6.0 Server to run the project. This is part of the error:
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
2012-jan-30 13:43:46 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:926)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
The Tomcat server has the following classpath: Bootstrap entries: JRSE System Library [jdk1.6.0_27], spring-2.5.2-20080220-410.jar. User entries: bootstrap.jar, tools.jar
Any ideas on how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要转到构建路径设置并确保包含 Apache Tomcat 库。
在项目资源管理器中右键单击您的项目名称,然后单击属性。在属性对话框中,单击左侧列表中的 Java Build Path,然后打开库选项卡。确认 Apache Tomcat 库是否存在。
如果不存在,请单击“添加库”->“添加库”。服务器运行时 -> Apache Tomcat v x.0 ->结束。
You need to go to your build path settings and make sure you have Apache Tomcat library included.
Right-click your project name from Project Explorer, click properties. In the properties dialog box, click Java Build Path from the list on left, then open libraries tab. Confirm if Apache Tomcat library is there.
If it is not there, click Add Library -> Server Runtime -> Apache Tomcat v x.0 -> Finish.
不管怎样,我终于通过右键单击项目名称 -> 摆脱了这个令人痛苦的问题。属性-> Java 构建路径 ->订购和出口。我检查了 JRE 系统库和 Maven 依赖项。
另一个问题是
pom.xml
引用了spring-core
两次。我删除了两者并手动添加了它:另外,检查 Project ->自动构建已启用。否则,类可能无法复制到 Tomcat 服务器。
希望这对某人有帮助。
For what it's worth, I finally got rid of this excruciating problem by right-clicking project name -> Properties -> Java Build Path -> Order and Export. I checked JRE System Library and Maven Dependencies.
Another problem was that
pom.xml
referencedspring-core
twice. I removed both and added this manually:Also, check that Project -> Build Automatically is enabled. Otherwise classes may not be copied to the Tomcat server.
Hope this helps somebody.
我解决了这个问题,将Tomcat文件夹移动到C:,然后在eclipse中重新安装服务器。这是一个权限问题,因为它之前在我的桌面文件夹中。
I solved this problem moving the Tomcat folder to C: and then reinstalling the server in eclipse. It was a permission issue because it was in my desktop folder before.
尝试使用以下版本的 Spring Web...
try using the following version of Spring web...