@Component vs @Service vs @Repository
These annotations register classes as components
The question library
Explore practical questions, clear explanations, and code examples across developer technologies.
Showing 1957–1968 of 3610 questions
These annotations register classes as components
A bean is an object managed by the Spring container
Singleton is the default scope: one instance per bean definition per container
Constructor injection makes required dependencies visible, enables final fields, and lets tests instantiate a class without starting Spring
Starters group compatible dependencies for a capability, such as web development or JPA persistence
Auto-configuration conditionally configures common components based on the classpath, properties, and existing beans
An embedded server lets an executable Spring Boot application start its web server itself, commonly allowing deployment as a JAR instead of deploying a WAR to a separately managed servlet container
Both formats externalize configuration
Profiles select environment-specific beans or configuration, such as local, test, and production
It binds a group of external configuration values into a typed Java object, making configuration easier to validate, document, and test than scattered string expressions
@Value injects a property or expression into a bean
@RestController combines controller registration with response-body behavior, so handler return values are serialized to the HTTP response, commonly as JSON