【问题标题】:Jetty | Deploy war and static content码头 |部署战争和静态内容
【发布时间】:2018-02-12 14:14:22
【问题描述】:

我正在尝试将 war 文件(包含我的 java 后端)和一些静态内容(包含已编译的 Angular 项目)部署到码头服务器。

首先它可以工作,但我想改进部署。 目前我的war文件是从webapp-project的目标目录部署的。静态内容(角度项目)从包含 web.xml 的 WEB-INF 文件夹所在的 src/main/webapp 目录部署。

但如果我可以从目标文件夹同时部署(war 文件和静态内容),那就太好了。

我在 pom.xml 中的当前配置:

<project xmlns="..." xmlns:xsi="..."
xsi:schemaLocation="...">
<modelVersion>4.0.0</modelVersion>
<groupId>...</groupId>
<artifactId>SurefireAuswerterBackend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-jetty-http</artifactId>
        <version>2.25.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-jetty-servlet</artifactId>
        <version>2.25.1</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.20.v20161216</version>
            <dependencies>
                <dependency>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-io</artifactId>
                    <version>9.2.20.v20161216</version>
                </dependency>
            </dependencies>
            <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <war>${project.basedir}/target/surefire-auswerter.war</war>
                <stopKey>alpha</stopKey>
                <stopPort>4445</stopPort>
                <httpConnector>
                    <port>4444</port>
                </httpConnector>
                <webAppSourceDirectory>${project.basedir}/target/surefire-auswerter</webAppSourceDirectory>
                <webAppConfig>
                    <contextPath>/surefire-auswerter</contextPath>
                </webAppConfig>
            </configuration>
        </plugin>
    </plugins>
</build>

我删除了一些不重要的配置。

我已经尝试了很多,例如设置 WebAppSourceDirectory 但没有任何效果。 是否有任何解决方案总是被使用或做我想要的?

PS:请原谅我的语言——我的英语还不是很熟练。 此外,这是我在 StackOverlow 上的第一个问题,如果我写的太模糊,请见谅。

我愿意接受批评。

感谢您的努力和回答!

【问题讨论】:

    标签: angular maven web-applications deployment jetty


    【解决方案1】:

    改用jetty:run-war 目标,这就是它存在的原因。

    https://www.eclipse.org/jetty/documentation/9.4.x/jetty-maven-plugin.html#running-assembled-webapp-as-war

    此外,Jetty 9.2.x 现已弃用,请升级到 Jetty 9.4.x。

    【讨论】:

    • 感谢您的回答 - 它为我指明了新的方向:我已经改变了构建自动化 - 现在我使用 Maven 构建后端并自动包含已编译的前端。现在我想使用 jetty:deploy-war 来部署这场组装战争。但它不按我想要的方式工作。 Maven 说“构建成功”,但是当我尝试在网络浏览器中打开它时,它什么也没显示。
    • 找到“问题”的解决方案:文档说,您可以使用 false,这对我有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 1970-01-01
    • 1970-01-01
    • 2011-11-01
    • 1970-01-01
    • 2011-04-16
    • 1970-01-01
    相关资源
    最近更新 更多