【问题标题】:How can I run appRunWar in a port other than the one defined in the build.gradle如何在 build.gradle 中定义的端口以外的端口中运行 appRunWar
【发布时间】:2016-02-15 03:08:21
【问题描述】:

我在尝试更改 Gretty 的端口时遇到问题,如 Gretty 文档中所述。

Gradle appRunWar -PhttpPort=8888 

唯一可行的方法是更改​​ build.gradle gretty 块

gretty {
    http = 8888
    contextPath = '/'
}

【问题讨论】:

标签: java gretty


【解决方案1】:

我在搜索 Gretty Possible Running Build in Different Ports Github 存储库后找到了解决方案。

你需要做的就是改变 build.gradle 文件如下

gretty {
    httpPort = project.hasProperty("httpPort") ? project.httpPort as int : 8080
    contextPath = '/'
}

另一种方法是添加以下内容

gradle.taskGraph.whenReady {
    graph ->
        if (project.hasProperty("httpPort")) {
            gretty.httpPort = httpPort as int
        }
}

两种解决方案都可以通过将属性参数传递给公会文件来工作

 gradle -PhttpPort=8888 

【讨论】:

    猜你喜欢
    • 2012-02-12
    • 2021-12-16
    • 2023-03-28
    • 1970-01-01
    • 2011-05-27
    • 1970-01-01
    • 2017-07-01
    • 2019-09-15
    • 1970-01-01
    相关资源
    最近更新 更多