Fork me on GitHub

Conditionals

Note: this page is only relevant for Spring Boot applications.

The autoconfiguration class of the starter module is guarded with ConditionalOnSystemd.

This conditional matches when all the following hold:

  • the application is running under Linux;
  • the environment property NOTIFY_SOCKET is set to a usable address: either the path of an existing socket file, or an address with no file, such as a socket in the abstract namespace (starting with @) or a vsock: address;
  • the notifications to systemd could be set up (see Native library): on Java 22 and later, with the Foreign Function and Memory API, unless native access is denied; otherwise, as on Java 17 to 21 or for vsock: addresses, the native libsystemd library could be loaded.

Should there be a need to provide custom jsystemd beans, such as custom StatusProvider implementations, it is preferable to use this conditional on the configuration class providing them, as it is preferable to not waste time building beans that will never be needed or used.

The same goes for configuration classes that use the Systemd instance of the process directly, with Systemd.instance().