启动jetty时报找不到spring webApplicationInitializer

来源:3-5 Hello Spring MVC

diligentdpf

2015-09-06 17:37

2015-09-06 17:22:48.519:INFO:/:main: No Spring WebApplicationInitializer types detected on classpath

2015-09-06 17:22:48.570:INFO:/:main: Initializing Spring root WebApplicationContext

log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).

log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

2015-09-06 17:22:48.712:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.m.p.JettyWebAppContext@73b634b1{/,file:/F:/Eclipseworkspace/spring-mvc-study/src/main/webapp/,STARTING}{file:/F:/Eclipseworkspace/spring-mvc-study/src/main/webapp/}

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]


写回答 关注

3回答

  • qq_happy的人儿_0
    2017-11-21 16:18:42

    public static void main(String[] args) {
      JFinal.start("src/main/webapp", 80, "/");// 启动配置项
    }

    将这里的端口号与

    pom.xml里面的port端口号一致就行

    <plugin>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-maven-plugin</artifactId>
      <version>9.2.2.v20140723</version>
      <configuration>
         <httpConnector>
            <port>80</port><!-- 启动端口号 -->
         </httpConnector>
         <stopPort>99</stopPort>
         <stopKey>stop</stopKey>
         <scanIntervalSeconds>10</scanIntervalSeconds>
         <webApp>
            <contextPath>/</contextPath>
         </webApp>
         <!-- 适应测试阶段的jetty,日志写入目录,tomcat写入tomcat/logs下 -->
         <systemProperties>
            <systemProperty>
               <name>catalina.base</name>
               <value>.</value>
            </systemProperty>
         </systemProperties>
      </configuration>
    </plugin>

    我是用IDEA的jetty启动的

  • sangbz
    2017-08-19 16:58:07

    [INFO] Initializing Spring root WebApplicationContext

    [INFO] started o.m.j.p.JettyWebAppContext{/,file:/E:/EclipseProject/Mybatis/web-parent/web-app/src/main/webapp/},file:/E:/EclipseProject/Mybatis/web-parent/web-app/src/main/webapp/

    [INFO] Initializing Spring FrameworkServlet 'dispatcher'

    [INFO] Started SelectChannelConnector@0.0.0.0:80

    [INFO] Started Jetty Server


  • MasqueZe
    2015-12-27 01:01:34

    估计你是不是乱改路劲了?

Spring MVC起步

Java中Spring MVC框架入门教程,快来看最易用的MVC框架

195972 学习 · 572 问题

查看课程

相似问题