2017-10-16 152 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文件。

对不起,但这并没有一个简单的解决方案。