liveBook · Manning

/beans endpoint

As explained in Spring in Action, Sixth Edition

The /beans endpoint is a Spring Boot Actuator HTTP endpoint that returns descriptions of the beans in the application contexts.

The /beans endpoint is a Spring Boot Actuator endpoint for exploring an application’s Spring application contexts. A GET request returns a JSON document describing every bean, including its Java type and injected dependencies. section 15.2.2

Read the response by following its context and bean structure:

  • The contexts element contains one entry for each Spring application context. section 15.2.2
  • Each context contains a beans element with details for all its beans. section 15.2.2
  • Each bean entry can show aliases, scope, Java type, class-file resource, and injected dependencies. section 15.2.2

Inspecting a controller bean

A bean named ingredientsController can appear with singleton scope, type tacos.ingredients.IngredientsController, and ingredientRepository listed as an injected dependency. This turns the application context’s wiring into inspectable JSON. section 15.2.2

{
  "contexts": {
    "application-1": {
      "beans": {
...
        "ingredientsController": {
          "aliases": [],
          "scope": "singleton",
          "type": "tacos.ingredients.IngredientsController",
          "resource": "file [/Users/habuma/Documents/Workspaces/
            TacoCloud/ingredient-service/target/classes/tacos/
            ingredients/IngredientsController.class]",
          "dependencies": [
            "ingredientRepository"
          ]
        },
...
      },
      "parentId": null
    }
  }
}

Browse a representative /beans response to see context, bean metadata, resource, and dependency fields together. section 15.2.2

How Spring in Action, Sixth Edition covers it

How deep it goes
Describes response structure and bean fields, but stops short of explaining endpoint configuration or complete response output.
Examples
Uses an ingredientsController entry showing singleton scope, Java type, class-file resource, and ingredientRepository dependency.
What you can do after
Evaluate/understand application-context contents and inspect which beans and dependencies Spring has assembled.
How it connects
Connects Spring application contexts with beans, dependency injection, singleton scope, and autoconfiguration.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.