簡體   English   中英

如何將Spring MVC部署到遠程Tomcat服務器

[英]How to deploy Spring MVC to remote Tomcat server

我遵循了一些 教程,並在eclipse中創建了SpringMVC Webapp。

我試圖將其部署在遠程運行的服務器下,但失敗了,不知道為什么?

這是我的工作:在以下目錄中: /fs/sda4/project/workspace/SpringMVC我執行了以下maven命令:

/opt/apache-maven-2.2.1/bin/mvn -Dmaven.test.skip=true clean install

構建成功。

然后我復制了以下戰爭文件

/fs/sda4/project/workspace/SpringMVC/target/SpringMVC.war

到服務器,更精確地在這里:

/usr/pkg/tomcat/webapps/

現在,我希望啟動Tomcat之后,以下URL應該將我帶到打開頁面。

https://gaya.aac.com:8843/SpringMVC/

但是它沒有,而是給了我一個http狀態404,請求的資源不可用。

這是tomcat啟動的相關日志:

       INFO: Starting service Catalina
    Jun 18, 2014 11:46:27 AM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
    Jun 18, 2014 11:46:27 AM org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive /usr/pkg/tomcat-rusznak/webapps/SpringMVC.war
    [WebappClassLoader@4c01acb7] info AspectJ Weaver Version 1.7.3 built on Thursday Jun 13, 2013 at 19:41:31 GMT
    [WebappClassLoader@4c01acb7] info register classloader org.apache.catalina.loader.WebappClassLoader@4c01acb7
    [WebappClassLoader@4c01acb7] info no configuration found. Disabling weaver for class loader org.apache.catalina.loader.WebappClassLoader@4c01acb7
    Jun 18, 2014 11:46:29 AM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    Jun 18, 2014 11:46:29 AM org.springframework.web.context.ContextLoader initWebApplicationContext
    INFO: Root WebApplicationContext: initialization started
    Jun 18, 2014 11:46:29 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
    INFO: Refreshing Root WebApplicationContext: startup date [Wed Jun 18 11:46:29 CEST 2014]; root of context hierarchy
    Jun 18, 2014 11:46:29 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]
    Jun 18, 2014 11:46:29 AM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
    INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
    Jun 18, 2014 11:46:29 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
    INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1b3c0cef: defining beans [helloController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0]; root of factory hierarchy
    Jun 18, 2014 11:46:29 AM org.springframework.web.context.ContextLoader initWebApplicationContext
    INFO: Root WebApplicationContext: initialization completed in 455 ms
    Jun 18, 2014 11:46:29 AM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring FrameworkServlet 'mvc-dispatcher'
    Jun 18, 2014 11:46:29 AM org.springframework.web.servlet.FrameworkServlet initServletBean
    INFO: FrameworkServlet 'mvc-dispatcher': initialization started
    Jun 18, 2014 11:46:29 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
    INFO: Refreshing WebApplicationContext for namespace 'mvc-dispatcher-servlet': startup date [Wed Jun 18 11:46:29 CEST 2014]; parent: Root WebApplicationContext
    Jun 18, 2014 11:46:29 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]
    Jun 18, 2014 11:46:29 AM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
    INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
    Jun 18, 2014 11:46:29 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
    INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@463e0db0: defining beans [helloController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1b3c0cef
    Jun 18, 2014 11:46:30 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
    INFO: Mapped URL path [/welcome] onto handler 'helloController'
    Jun 18, 2014 11:46:30 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
    INFO: Mapped URL path [/welcome.*] onto handler 'helloController'
    Jun 18, 2014 11:46:30 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
    INFO: Mapped URL path [/welcome/] onto handler 'helloController'
    Jun 18, 2014 11:46:30 AM org.springframework.web.servlet.FrameworkServlet initServletBean
    INFO: FrameworkServlet 'mvc-dispatcher': initialization completed in 343 ms
    Jun 18, 2014 11:46:30 AM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler ["http-bio-8843"]
    Jun 18, 2014 11:46:30 AM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 2341 ms
Jun 18, 2014 11:49:16 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:49:22 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/WEB-INF/pages/hello.jsp] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:50:00 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:50:06 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/WEB-INF/pages/hello.jsp] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:53:20 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/WEB-INF/pages/hello.jsp] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:53:58 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 12:31:27 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/WEB-INF/pages/hello.jsp] in DispatcherServlet with name 'mvc-dispatche

這是web.xml

<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>Spring Web MVC Application</display-name>

<servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

這是mvc-dispatcher.servlet

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans     
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="com.mkyong.common.controller" />

<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
        <value>/WEB-INF/pages/</value>
    </property>
    <property name="suffix">
        <value>.jsp</value>
    </property>
</bean>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM