2017-10-16 156 views
0

我想將基於Spring MVC的maven項目部署到Tomcat服務器中。 我一直在本地模式下使用eclipse + tomcat 7,並且該項目正常工作,但現在,我購買了PLESK主機並且該應用無法正常工作。在Tomcat中部署Spring MVC + Maven 7

我建立與Maven插件方法.WAR(目標乾淨安裝,ADN JDK 1.8編譯器): enter image description here

結果: enter image description here

我有一個正常的WEP應用程序.war文件和測試主機工作正常,爲此我認爲這個問題是我的項目在構建.war文件之前的結構......但我不知道。

Sample.war結構:

enter image description here

我現在的結構是這樣的(使用Spring MVC Maven項目):

enter image description here

的我的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>TreeBuk</groupId> 
<artifactId>TreeBuk</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>war</packaging> 
<build> 
    <sourceDirectory>src</sourceDirectory> 
    <plugins> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.3</version> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.6</version> 
      <configuration> 
       <warSourceDirectory>WebContent</warSourceDirectory> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

我的inde x.jsp和我所有的其他視圖都進入WebContent/WEB-INF/views。我看到一些例子,其中index.jsp是在WebContent/WEB-INF/...但我不知道爲什麼...另一方面,我測試它在本地服務器tomcat太(沒有在日食實例),但不工作部署...我不明白爲什麼工作到tomcat實例上的eclipse,但在本地tomcat服務器不工作

任何人都可以幫我部署我的wepApp在服務器?哪裏有問題?

PD:使用Apache Tiles 3.0,一些.xml配置文件(security-context.xml,persistence-context.xml,服務上下文等等,除了WebContent/src/com.treebuk/WEB-INF /調度-servlet.xml文件)

編輯1: 當啓動本地Tomcat服務器執行的apache-tomcat的-7.0.67 \ BIN \ startip.bat我可以在控制檯中看到這一點: enter image description here

如果我去url http://localhost:8080/TreeBuk/ enter image description here

EDIT 2 在我的web.xml文件我已經配置了多上下文文件的XML。 (提醒的是,應用程序的工作原理到Eclipse的Tomcat服務器實例)

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
     classpath:com/treebuk/config/persistence-context.xml 
     classpath:com/treebuk/config/service-context.xml 
     classpath:com/treebuk/config/security-context.xml 
     classpath:com/treebuk/config/application-context.xml 
    </param-value> 
</context-param> 
+0

一個小建議,對java項目使用intellij思想。在intellij中你會很輕鬆地做事。 – SAM

+0

你的例外說明,你構建的應用程序搜索名爲'persistence-context.xml'的文件,但它不存在於你的類路徑中。你把這個文件放在那條路上了嗎? –

+0

@AtaurRahmanMunna couse,我將src/com/treebuk/config中的測試配置.xml文件更改爲WEB-INF,並將classpath值更改爲WEB-INF/persistence-context.xml ..並且信息消息更改爲表明資源找不到....我試着解決了這個問題......但我不明白爲什麼在eclipse和其他服務器的tomcat服務器實例工作... –

回答

0

Finnaly,我不知道happend,但.WAR的結構是無效的......我重建一個新的Spring MVC項目與項目其他有效的結構,我可以生成.war文件。

對不起,但這並沒有一個簡單的解決方案。