Configuration class
A configuration class is a class that declares settings, components, or other metadata used to configure an application, framework, or container.
Spring Start Here, Second Edition
A configuration class is a Spring class annotated with @Configuration that declares instructions for configuring the Spring context.
- How it is used
- Uses configuration classes to instruct Spring how to populate and configure its context.
- How deep it goes
- Works through bean creation, context initialization, multiple-bean selection, component scanning, and relationships between beans.
- Examples
- Uses a named Parrot bean, multiple parrots, and a Person–Parrot relationship to illustrate configuration.
- What you can do after
- Apply it via Spring to declare beans, configure component scanning, and establish bean relationships.
Read how Spring Start Here, Second Edition explains configuration class →
Spring in Action, Sixth Edition
A Spring annotation marking a Java class as a source of bean definitions for the application context.
- How it is used
- Uses configuration classes to define beans and register Spring MVC view controllers.
- How deep it goes
- Explains annotation roles and bean method behavior, then walks through registering a view controller.
- Examples
- Shows service beans wired through a constructor and a web configuration mapping / to the home view.
- What you can do after
- Apply it via Spring to declare beans and configure a view controller.
Read how Spring in Action, Sixth Edition explains configuration class →
Testing Spring Boot Applications
A configuration class is a class that declares application configuration, including component or bean definitions, for a framework container.
- How it is used
- Configures Spring application contexts and supplies shared or selectively included beans for integration tests.
- How deep it goes
- Explains package discovery, explicit test inclusion, and configuration override behavior, but stops short of bean lifecycle internals.
- Examples
- Uses production and test package layouts, nested @TestConfiguration, @Bean declarations, and explicit @Import.
- What you can do after
- Apply @Configuration, @TestConfiguration, and @Import to control which beans enter Spring Boot test contexts.
Read how Testing Spring Boot Applications explains configuration class →
Also covered in
- Spring Security in Action, Second Edition
- Applied Reinforcement LearningIn early access (MEAP)
Related concepts
- @Configurationconfigured by · @Configuration is a Spring annotation that marks a class as a source of configuration, including bean definitions, for the application context.
- @SpringBootApplicationconfigured by · @SpringBootApplication is a Spring Boot annotation that combines application configuration, auto-configuration, and component scanning.
- @profileconfigured by · @Profile is a Spring annotation that conditionally registers bean definitions or configuration classes when specified application profiles are active.
- component annotationalternative to · The Spring @Component annotation marks a class as eligible for automatic detection and registration as a Spring bean.
Questions about configuration class
What is configuration class?
A configuration class is a class that declares settings, components, or other metadata used to configure an application, framework, or container.
Which Manning books explain configuration class?
Spring Start Here, Second Edition, Spring in Action, Sixth Edition and Testing Spring Boot Applications.
What is the difference between configuration class and component annotation?
A configuration class is a class that declares settings, components, or other metadata used to configure an application, framework, or container. The Spring @Component annotation marks a class as eligible for automatic detection and registration as a Spring bean.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


