Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Spring
Springeasy

What do `@Configuration` and `@Bean` do in Spring?

Tags
#configuration#bean#spring-core
Back to categoryPractice quiz

Answer

`@Configuration` marks a class that defines Spring beans. `@Bean` marks a method whose return value should be managed by Spring as a bean (created, injected, lifecycle handled).

@Configuration
class AppConfig {
  @Bean
  Clock clock() {
    return Clock.systemUTC();
  }
}

Related questions

Spring
What does `@Profile` do in Spring and when would you use it?
#spring#profiles#configuration
Spring
`@ConfigurationProperties` vs `@Value`: when should you prefer `@ConfigurationProperties`?
#spring-boot#configuration#properties
Spring
Spring Boot auto‑configuration: how does it work at a high level?
#spring-boot#auto-configuration#starters
Spring
Spring Boot config precedence: which sources typically override which?
#spring-boot#configuration#profiles
Spring
Why use `@ConfigurationProperties` instead of many `@Value` annotations?
#spring-boot#configuration#properties
Spring
What does `@Profile` do in Spring?
#profiles#configuration#spring