Chapter 15. Jersey configuration
Prev |  | Next

Links: Table of Contents | Single HTML

# Chapter 15. Jersey configuration

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.

## 15.1. Jersey default configuration provider

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.

## 15.2. Micro profile configuration provider

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:

                    NAME=VALUE

Then Jersey Microprofile Config extension is needed to be added:

                    <dependency>
                        <groupId>org.glassfish.jersey.ext.microprofile</groupId>
                        <artifactId>jersey-mp-config</artifactId>
                        <version>3.0.9</scope>
                    </dependency>

And the Microprofile Config implementation, such as Helidon:

                    <dependency>
                        <groupId>io.helidon.microprofile.config</groupId>
                        <artifactId>helidon-microprofile-config</artifactId>
                        <version>2.1.0</version>
                    </dependency>

Or SmallRye:

                    <dependency>
                        <groupId>io.smallrye</groupId>
                        <artifactId>smallrye-config</artifactId>
                        <version>1.5.0</version>
                    </dependency>

or any other suitable Microprofile Config implementation.

Prev |  | Next
Chapter 14. Programmatic API for Building Resources | Home | Chapter 16. Server-Sent Events (SSE) Support