如何在 openshift.com 上部署 Spring MVC 项目

how to deploy Spring MVC project on openshift.com

我想部署一个简单的 Spring MVC APP 来打开轮班我用谷歌搜索并找到了 spring-mvc-3-on-jboss 但是项目结构不同我有基本的 Spring MVC 项目结构是


this repo,在 openshift.com 我创建了应用程序并配置为:

但是当我转到我的应用程序时,我看不到 home.jsp 文件作为欢迎文件-url 我只看到 default/traditional 欢迎页面。
有什么关于如何配置项目以使其正常工作的建议吗?

首先您克隆了 git 存储库,然后在文档文件夹中自动创建了文件夹。

然后将您的 war 文件解压缩并将您的克隆目录复制到 webapps 文件夹中

并创建测试文件夹将您的代码粘贴到文件夹和根 war 文件中。

然后你的文件夹名里的ulr写进去。

例如

像这样。

git clone ssh://5565c850e0b8cd07580001ba@yourdomain.rhcloud.com

将提取的 war 文件粘贴到克隆目录中。

然后触发 git 命令

$ git add .
$ git commit -m "A checkin to my application"
$ git push

您的 pom.xml 存在一个主要问题,我认为这会导致您的应用无法在 openshift.com 上运行。您应该将以下行添加到 pom.xml

<profiles>
    <profile>
        <!-- When built in OpenShift the 'openshift' profile will be used when 
            invoking mvn. -->
        <!-- Use this profile for any OpenShift specific customization your app 
            will need. -->
        <!-- By default that is to put the resulting archive into the 'webapps' 
            folder. -->
        <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
        <id>openshift</id>
        <build>
            <finalName>yourAppName</finalName>
            <plugins>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <configuration>
                        <outputDirectory>webapps</outputDirectory>
                        <warName>ROOT</warName>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

我还没有用 JBoss Application Server 测试此代码,因此请将您的服务器更改为 Apache Tomcat 7。这对我很有效。