简体   繁体   English

Gradle Jetty插件如何在特定的IP地址和端口号上运行它

[英]Gradle jetty plugins how to run it on a specific ip address and port number

I have a web service which is executable with gradle jettyRun task. 我有一个可通过gradle jettyRun任务执行的Web服务。 If I run it runs on localhost:8080 . 如果我运行,它将在localhost:8080上运行。 I want to run it on a specific ip address and port number. 我想在特定的IP地址和端口号上运行它。 My current build.gradle is as follows: 我当前的build.gradle如下:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'jetty'

jettyRun {
   reload = "automatic"
   scanIntervalSeconds = 10
}

Other dependencies are removed. 其他依赖项已删除。 I know about the docs I just don't know the syntax. 我知道有关文档的知识,但我不知道语法。 How to configure host and port? 如何配置主机和端口?

What You need is: 您需要的是:

//other plugins
apply plugin: 'jetty'

httpPort = 9000

jettyRun {
   reload = "automatic"
   scanIntervalSeconds = 10
}

As far as I know host isn't configurable - You just run it and it depends on os specific configuration if it's accessible from other hosts or not. 据我所知,主机是不可配置的-您只需运行它,并且它是否依赖于os特定的配置(是否可以从其他主机访问)。

Adding to @Opal answer, you can also run Jetty at a specific port by using below configuration in build.gradle : 除了@Opal答案,您还可以通过在build.gradle使用以下配置在特定端口上运行Jetty:

jettyRun {
   reload = "automatic"
   scanIntervalSeconds = 10
   httpPort = 9999
}

or shorthand version jettyRun.httpPort = 9999 或简写版本jettyRun.httpPort = 9999

And for jettyRunWar task with following configuration: 对于具有以下配置的jettyRunWar任务:

jettyRunWar {
       reload = "automatic"
       scanIntervalSeconds = 10
       httpPort = 9999
}

or jettyRunWar.httpPort=9999 jettyRunWar.httpPort=9999

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM