Documentation

You are viewing the documentation for the 2.9.x release series. The latest stable release series is 3.0.x.

§The Typesafe Config API

Play uses the Typesafe config library as the configuration library. If you’re not familiar with Typesafe config, you may also want to read the documentation on configuration file syntax and features.

§Accessing the configuration

Typically, you’ll obtain a Config object through Dependency Injection, or simply by passing an instance of Config to your component:

/*
 * Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>
 */

package controllers

import com.typesafe.config.Config;
import javax.inject.Inject;
import play.mvc.Controller;

public class MyController extends Controller {

  private final Config config;

  @Inject
  public MyController(Config config) {
    this.config = config;
  }
}

§API documentation

Since Play just uses Config object, you can see the javadoc for the class to see what you can do and how to access configuration data.

Next: HTTP programming


Found an error in this documentation? The source code for this page can be found here. After reading the documentation guidelines, please feel free to contribute a pull request. Have questions or advice to share? Go to our community forums to start a conversation with the community.