java / beginner
Snippet
Defining Generic Beans with @Component
The @Component annotation marks a Java class as a bean so that Spring's component-scanning mechanism can pick it up and pull it into the application context.
snippet.java
1
2
3
4
5
6
@Componentpublic class SimpleTool {public String getInfo() {return "Tool is active";}}
spring
Breakdown
1
@Component
Indicates that an annotated class is a 'component' managed by Spring.