Tomcat run-java.lang.ClassCastException:org.apache.jasper.servlet.JspServlet无法强制转换为javax.servlet.Servlet

时间:2015-09-16 13:53:03

标签: eclipse spring maven

我已经尝试了两天,但错误

  

java.lang.ClassCastException:org.apache.jasper.servlet.JspServlet   无法转换为javax.servlet.Servlet

     

java.lang.ClassCastException:   org.springframework.web.servlet.DispatcherServlet无法强制转换为   javax.servlet.Servlet

我的控制台显示

     [INFO] Scanning for projects...

>     [INFO]                                                                         
>     [INFO] ------------------------------------------------------------------------
>     [INFO] Building NEWTRY11 0.0.1-SNAPSHOT
>     [INFO] ------------------------------------------------------------------------
>     [INFO] 
>     [INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) > compile @ NEWTRY11 >>>
>     [INFO] 
>     [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ NEWTRY11 ---
>     [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
>     [INFO] Copying 42 resources
>     [INFO] 
>     [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ NEWTRY11 ---
>     [INFO] Changes detected - recompiling the module!
>     [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
>     [INFO] Compiling 9 source files to F:\workspace\NEWTRY11\target\classes
>     [WARNING] /F:/workspace/NEWTRY11/src/main/entity/model/HibernateUtil.java:
> F:\workspace\NEWTRY11\src\main\entity\model\HibernateUtil.java uses or
> overrides a deprecated API.
>     [WARNING] /F:/workspace/NEWTRY11/src/main/entity/model/HibernateUtil.java:
> Recompile with -Xlint:deprecation for details.
>     [INFO] 
>     [INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) < compile @ NEWTRY11 <<<
>     [INFO] 
>     [INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @ NEWTRY11 ---
>     [INFO] Running war on http://localhost:8080/NEWTRY11
>     [INFO] Creating Tomcat server configuration at F:\workspace\NEWTRY11\target\tomcat
>     Sep 16, 2015 6:59:12 PM org.apache.catalina.startup.Embedded start
>     INFO: Starting tomcat server
>     Sep 16, 2015 6:59:12 PM org.apache.catalina.core.StandardEngine start
>     INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
>     Sep 16, 2015 6:59:13 PM org.apache.catalina.core.ApplicationContext log
>     INFO: Marking servlet spring as unavailable
>     Sep 16, 2015 6:59:13 PM org.apache.catalina.core.StandardContext loadOnStartup
>     SEVERE: Servlet /NEWTRY11 threw load() exception
>     java.lang.ClassCastException: org.springframework.web.servlet.DispatcherServlet cannot be cast to
> javax.servlet.Servlet
>       at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
>       at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
>       at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
>       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
>       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>       at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
>       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>       at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
>       at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
>       at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)
>       at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)
>       at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
>       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
>       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
>       at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
>       at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
>       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
>       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
>       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
>       at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
>       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
>       at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:497)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
>     
>     Sep 16, 2015 6:59:13 PM org.apache.catalina.core.ApplicationContext log
>     INFO: Marking servlet jsp as unavailable
>     Sep 16, 2015 6:59:13 PM org.apache.catalina.core.StandardContext loadOnStartup
>     SEVERE: Servlet /NEWTRY11 threw load() exception
>     java.lang.ClassCastException: org.apache.jasper.servlet.JspServlet cannot be cast to javax.servlet.Servlet
>       at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
>       at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
>       at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
>       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
>       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>       at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
>       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>       at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
>       at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
>       at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)
>       at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)
>       at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
>       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
>       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
>       at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
>       at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
>       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
>       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
>       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
>       at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
>       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
>       at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:497)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
>     
>     Sep 16, 2015 6:59:13 PM org.apache.tomcat.util.modeler.Registry registerComponent
>     SEVERE: Null component localEngine:type=JspMonitor,name=jsp,WebModule=//localhost/NEWTRY11,J2EEApplication=none,J2EEServer=none
>     Sep 16, 2015 6:59:13 PM org.apache.coyote.http11.Http11Protocol init
>     SEVERE: Error initializing endpoint
>     java.net.BindException: Address already in use: JVM_Bind <null>:8080
>       at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549)
>       at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:176)
>       at org.apache.catalina.connector.Connector.initialize(Connector.java:1014)
>       at org.apache.catalina.startup.Embedded.start(Embedded.java:830)
>       at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)
>       at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)
>       at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
>       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
>       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
>       at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
>       at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
>       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
>       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
>       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
>       at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
>       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
>       at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:497)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>       at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
>     Caused by: java.net.BindException: Address already in use: JVM_Bind
>       at java.net.DualStackPlainSocketImpl.bind0(Native Method)
>       at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
>       at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
>       at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
>       at java.net.ServerSocket.bind(ServerSocket.java:375)
>       at java.net.ServerSocket.<init>(ServerSocket.java:237)
>       at java.net.ServerSocket.<init>(ServerSocket.java:181)
>       at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:50)
>       at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538)
>       ... 27 more
>     
>     [INFO] ------------------------------------------------------------------------
>     [INFO] BUILD FAILURE
>     [INFO] ------------------------------------------------------------------------
>     [INFO] Total time: 5.991 s
>     [INFO] Finished at: 2015-09-16T18:59:13+05:30
>     [INFO] Final Memory: 25M/187M
>     [INFO] ------------------------------------------------------------------------
>     [ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:run (default-cli) on project
> NEWTRY11: Could not start Tomcat: Protocol handler initialization
> failed: java.net.BindException: Address already in use: JVM_Bind
> <null>:8080 -> [Help 1]
>     [ERROR] 
>     [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
>     [ERROR] Re-run Maven using the -X switch to enable full debug logging.
>     [ERROR] 
>     [ERROR] For more information about the errors and possible solutions, please read the following articles:
>     [ERROR] [Help 1] http://cwiki.apache.org/confluence/display /MAVEN/MojoExecutionException

我的pom.xml提供了javax范围

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>

我的完整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>NEWTRY11</groupId>
  <artifactId>NEWTRY11</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <dependencies>
  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-annotations-api</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-catalina-ant</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-catalina-ha</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-tribes</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-catalina</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jdt.core.compiler</groupId>
      <artifactId>ecj</artifactId>
      <version>4.2.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-el-api</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jasper-el</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jasper</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jsp-api</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.13</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-servlet-api</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-api</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-coyote</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-dbcp</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-i18n-es</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-i18n-fr</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-i18n-ja</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jdbc</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-util</artifactId>
      <version>7.0.34</version>
    </dependency>
    <dependency>
      <groupId>antlr</groupId>
      <artifactId>antlr</artifactId>
      <version>2.7.7</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.3</version>
    </dependency>
    <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <version>1.6.1</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate.common</groupId>
      <artifactId>hibernate-commons-annotations</artifactId>
      <version>4.0.5.Final</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>4.3.11.Final</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate.javax.persistence</groupId>
      <artifactId>hibernate-jpa-2.1-api</artifactId>
      <version>1.0.0.Final</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-osgi</artifactId>
      <version>4.3.11.Final</version>
    </dependency>
    <dependency>
      <groupId>org.jboss</groupId>
      <artifactId>jandex</artifactId>
      <version>1.1.0.Final</version>
    </dependency>
    <dependency>
      <groupId>org.javassist</groupId>
      <artifactId>javassist</artifactId>
      <version>3.18.1-GA</version>
    </dependency>
    <dependency>
      <groupId>org.jboss.logging</groupId>
      <artifactId>jboss-logging</artifactId>
      <version>3.1.3.GA</version>
    </dependency>
    <dependency>
      <groupId>org.jboss.logging</groupId>
      <artifactId>jboss-logging-annotations</artifactId>
      <version>1.2.0.Beta1</version>
    </dependency>
    <dependency>
      <groupId>org.jboss.spec.javax.transaction</groupId>
      <artifactId>jboss-transaction-api_1.2_spec</artifactId>
      <version>1.0.0.Final</version>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.compendium</artifactId>
      <version>4.3.1</version>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.core</artifactId>
      <version>4.3.1</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aspects</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>4.1.6.RELEASE</version>
      <classifier>sources</classifier>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>4.1.6.RELEASE</version>
      <classifier>sources</classifier>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-expression</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-oxm</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-websocket</artifactId>
      <version>4.1.6.RELEASE</version>
    </dependency>
  </dependencies>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

我的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" 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>youTube</display-name>
 <servlet>  
    <servlet-name>spring</servlet-name>  
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
    <load-on-startup>1</load-on-startup>  
</servlet>  
<servlet-mapping>  
    <servlet-name>spring</servlet-name>  
    <url-pattern>/</url-pattern>  
</servlet-mapping> 
</web-app>

0 个答案:

没有答案