在VMWare vFabric tc Server和Maven中找不到org.springframework.web.servlet.DispatcherServlet [英] org.springframework.web.servlet.DispatcherServlet not found with VMWare vFabric tc Server and maven

查看:106
本文介绍了在VMWare vFabric tc Server和Maven中找不到org.springframework.web.servlet.DispatcherServlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道之前有一个与这个问题非常相似的问题.但是解决方案不适用于我的问题.

I know that there is a previously posted question that is very similar to this one. But the solution doesn't apply to my problem.

我正在尝试使用Maven启动一个基本的Spring项目. 这是我的pom.xml:

I'm trying to start a basic Spring project with Maven. This is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>es.indra</groupId>
  <artifactId>springappUV</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>
    <org.springframework.version>3.1.1.RELEASE</org.springframework.version>
  </properties>
  <packaging>war</packaging>
  <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
  </dependencies>
</project>

这是我的web.xml:

This is my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>springappUV</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

  <servlet>
    <servlet-name>springapp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>/WEB-INF/spring/app-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>springapp</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>
</web-app>

我正在使用VMWare vFabric tc Server Developer Edition v2.6(STS附带的版本).当我用它运行webapp时,出现以下错误:

I am using VMWare vFabric tc Server Developer Edition v2.6 (the one that comes with STS). When I run the webapp with it, I get the following error:

GRAVE: El Servlet /springappUV lanzó excepción de load()
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1043)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
06-jul-2012 14:06:56 org.apache.catalina.startup.HostConfig deployDirectory

我知道它必须与依赖项有关,但是在Maven依赖项中,jar spring-webmvc-3.1.1.RELEASE.jar包含错误指出的类. 因此,似乎服务器不知道该库在那里.

I know it must have to do with the dependencies, but in the Maven dependencies the jar spring-webmvc-3.1.1.RELEASE.jar contains the class that the error says is missing. So it seems that the server doesn't know that the library is there.

有人知道会发生什么吗?

Does anyone know what could be happening?

谢谢!

推荐答案

您必须在部署程序集中包括maven依赖项-它们尚未部署到Web服务器.这就是您解决日食错误的方法,我想STS会与此类似.

You must include maven dependencies in the deployment assembly - they are not being deployed to the webserver. That's how you fix that error in eclipse, I guess STS will be similar.

这篇关于在VMWare vFabric tc Server和Maven中找不到org.springframework.web.servlet.DispatcherServlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆