简体   繁体   中英

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. If I run it runs on localhost:8080 . I want to run it on a specific ip address and port number. My current build.gradle is as follows:

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.

Adding to @Opal answer, you can also run Jetty at a specific port by using below configuration in build.gradle :

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

or shorthand version jettyRun.httpPort = 9999

And for jettyRunWar task with following configuration:

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

or jettyRunWar.httpPort=9999

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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