Hands-On Cloud Development with WildFly
上QQ阅读APP看书,第一时间看更新

System properties

You are able to modify the configuration by specifying system properties. Let's return to our catalog-service. As you saw in the catalog-service examples from the last chapter, the JAX-RS application was listening for HTTP requests on port 8080, which is the default configuration. Let's suppose that we want to change that port.

What we have to do is specify the swarm.http.port property during the application execution, as follows:

mvn clean wildfly-swarm:run -Dswarm.http.port=12345

When running the web browser, we can see that, indeed, the port on which the application runs has been changed:

What has just happened here then? The undertow fraction has discovered that there is a configuration property that overrides the standard HTTP port, and it modifies the socket's configuration accordingly. As a result, the running application is using the specified port.

Each fraction contains a group of properties that can be used to configure it. You will be able to find them in Swarm documentation.

The method of editing the properties is very simple and can be sufficient in many cases, but the entry point to the more complex programmatic configurations may be more feasible let's learn how to do it.