简体   繁体   中英

deploy a Spring MVC + Maven in Tomcat 7

I want to deploy a maven project based in Spring MVC into a Tomcat server . I have been working with eclipse + tomcat 7, in local mode, and the project work correctly, but now, i buy a host with PLESK and the app doesnt work.

I build a .WAR with maven plugin method (Goal clean install, adn JDK 1.8 compiler): 在此处输入图片说明

The result: 在此处输入图片说明

I test with a normal wep app .war file and the host work correctly, for this reason i suppouse that the problem is the structure of my proyect before build the .war file... but i dont know.

Sample.war struct:

在此处输入图片说明

My current structure is this (Maven project using Spring MVC) :

在此处输入图片说明

An the lines of my 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>

My index.jsp and all my other views is into WebContent/WEB-INF/views . I saw some examples where index.jsp is in WebContent/WEB-INF/... but i dont know why...For other hand, i test it in local server tomcat too (no in eclipse instance) but dont work the deployment... I dont understand why WORK into eclipse on tomcat instance, but in local tomcat server doesnt work .

Anybody can help me to deploy my wepApp in server? Where is the problem?

PD: im using Apache Tiles 3.0, some .xml configuration files (security-context.xml, persistence-context.xml, service-context, etc, into src/com.treebuk/config in addition to WebContent/WEB-INF/dispatcher-servlet.xml file)

EDIT 1 : When start the local tomcat server executing apache-tomcat-7.0.67\\bin\\startip.bat I can see this in the console: 在此处输入图片说明

and if I go to url http://localhost:8080/TreeBuk/ 在此处输入图片说明

EDIT 2 In my web.xml file I have configured the multi context files xml. (remind that the app works into tomcat server instance of Eclipse)

<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>

Finnaly, I dont know that happend, but the structure of .War was invalid... i rebuild the project in a new Spring MVC project with other valid structure and i could to generate the .war file.

Sorry but this havent a simple solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM