Table of Contents
This chapter provides Jersey configuration basics which includes configuration using default configuration provider (included in Jersey by default) using system properties, and micro-profile configuration extension which allows plugging-in of configuration modules based on micro profile configuration specification.
Since Jersey 2.29 it is possible to turn on the ability to convert the System properties into Configuration properties. That can be done by using the System property, too:
java -Djersey.config.allowSystemPropertiesProvider=true -DNAME=VALUE
Note that with the security manager turned on, write access permission is required to execute System.getProperties(). With insufficient permissions, the warning message is logged (with Level.FINER) and only CommonProperties, ClientProperties, and ServerProperties properties are used, as the property names are known and System.getProperty(name) method can be used, which does not require the write access permission.
Microprofile platform became very popular lately and Microprofile Config Specification is a recommended way in the Jakarta EE world to configure the specifications under the Jakarta EE umbrella.
Jersey 2.29 comes with support for Microprofile Config implementation such as Helidon or SmallRye. To configure the Jersey application, the microprofile-config.properties file needs to be created in the META-INF folder. The required properties are then simply set in the microprofile-config.properties:
Then Jersey Microprofile Config extension is needed to be added:
<dependency> <groupId>org.glassfish.jersey.ext.microprofile</groupId> <artifactId>jersey-mp-config</artifactId> <version>2.35</scope> </dependency>
And the Microprofile Config implementation, such as Helidon:
<dependency> <groupId>io.helidon.microprofile.config</groupId> <artifactId>helidon-microprofile-config</artifactId> <version>1.0.3</version> </dependency>
<dependency> <groupId>io.smallrye</groupId> <artifactId>smallrye-config</artifactId> <version>1.5.0</version> </dependency>
or any other suitable Microprofile Config implementation.