【问题标题】:deploying multiple wars using maven- jetty, tomcat?使用 maven-jetty、tomcat 部署多场战争?
【发布时间】:2012-08-02 20:09:34
【问题描述】:

我想部署多个 web 应用程序并运行 maven jetty 插件或 tomcat 插件。 但我似乎无法让他们工作。 我的主要目标是启动所有 webapps 的服务器,因为它们相互依赖。 我如何实现这一目标? 我尝试使用 maven jetty 插件 - 创建了一个带有多个 contextHandlers 的单独项目

<plugin>
        <groupId>org.mortbay.jetty</groupId>    
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.1.2.v20120308</version>
        <configuration>
            <contextHandlers>
                <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                    <contextPath>/data-emulator</contextPath>
                    <resourceBase>${basedir}/../data-emulator/target/</resourceBase>

                </contextHandler>

                <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                    <contextPath>/service</contextPath>
                    <resourceBase>${basedir}/../service/target/</resourceBase>

                </contextHandler>

                <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                    <contextPath>/client</contextPath>
                    <resourceBase>${basedir}/../client/target/</resourceBase>

                </contextHandler>
            </contextHandlers>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> 
                <port>8080</port>
                <maxIdleTime>60000</maxIdleTime>
            </connector>

        </configuration>
    </plugin>

【问题讨论】:

标签: java web-applications maven jetty


【解决方案1】:

您的 resourceBase 参数不正确。 target 文件夹不包含您的网页和 WEB-INF 文件夹(除非您有复制输出文件的特殊构建后任务)。

您应该改用 war 参数。下面的例子:

<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
    <contextPath>/data-emulator</contextPath>
    <war>${basedir}/../data-emulator/target/data-emulator.war</war>    
</contextHandler>

【讨论】:

  • > 您必须使用 org.eclipse.jetty.maven.plugin.JettyWebAppContext 实例而不是标准的 org.eclipse.jetty.webapp.WebAppContext 实例。只有前者才能让 webapp 在 maven 环境中正常运行。
猜你喜欢
  • 2014-08-20
  • 1970-01-01
  • 2013-03-23
  • 2014-01-19
  • 1970-01-01
  • 2013-12-27
  • 1970-01-01
  • 2011-10-20
  • 2020-01-06
相关资源
最近更新 更多