Este conteúdo não está disponível no idioma selecionado.

Chapter 5. Accessing the configuration from code


You can access the configuration by using a method defined in your code. You can achieve dynamic lookups or retrieve configured values from classes that are either CDI beans or JAX-RS resources.

You can access the configuration using the org.eclipse.microprofile.config.ConfigProvider.getConfig() method. The getValue method of the Config object returns the values of the configuration properties.

Prerequisites

  • You have a Quarkus Maven project.

Procedure

  • Access the configuration using one of the following options:

    • To access a configuration of a property that is defined already in your application.properties file, use the following syntax where DATABASE.NAME is the name of a property that is assigned to a databaseName variable:

      String databaseName = ConfigProvider.getConfig().getValue("DATABASE.NAME", String.class);
      Copy to Clipboard Toggle word wrap
    • To access a configuration of a property that might not be defined in your application.properties file, use the following syntax:

      Optional<String> maybeDatabaseName = ConfigProvider.getConfig().getOptionalValue("DATABASE.NAME", String.class);
      Copy to Clipboard Toggle word wrap
Voltar ao topo
Red Hat logoGithubredditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

Theme

© 2025 Red Hat