我在尝试更改 Gretty 的端口时遇到问题,如 Gretty 文档中所述。
Gradle appRunWar -PhttpPort=8888
它起作用的唯一方法是更改 build.gradle gretty 块
gretty {
http = 8888
contextPath = '/'
}
在不同端口Github 存储库中搜索 Gretty Possible Running Build后,我找到了解决方案。
您需要做的就是更改 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