Configuring OpenLiberty

OpenLiberty provides a rightsized server. In order for the Maven/Gradle plugin to incorporate the libraries required for the application, a configuration file named server.xml is introduced. A standard Java project layout, as defined by Maven, contains two folders in the main/ folder:

  • Java folder with .java files
  • Resources folder with files related to the application, but not containing code

When OpenLiberty is used, a third directory named liberty/ must be placed into the main/ folder. Within the liberty/ directory, there is one more subdirectory, named config/, to be found, which is where the OpenLiberty server.xml configuration file resides. The hierarchy can be observed in the following filesystem tree:

A minimalistic version of server.xml contains only a list of features required to be present for the application during its deployment. For a simple RESTful Microservice, there is only one feature to add. If more features are required, for example CDI for dependency injection or JPA for object-relational mapping and persistence, then including more <feature> tags with feature names inside is the obvious choice. Each feature contains the name of the feature complemented with a version. An exhaustive list of existing features can be found on OpenLiberty's GitHub page: github.com/OpenLiberty/open-liberty.

<server>
<featureManager>
<feature>jaxrs-2.0</feature>
</featureManager>
</server>

The destination of the server.xml file can be changed in Maven's pom.xml where the liberty-maven-plugin is configured. Inside the liberty-maven-plugin configuration, there is a <configFile> tag to be found. The value used for this book corresponds with the path described in this chapter and is configured as <configFile>src/main/liberty/config/server.xml</configFile>.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.164.34