Professional Documents
Culture Documents
20 Annotations Overview
20 Annotations Overview
Annotations
What are Java Annotations?
www.luv2code.com
Annotation Example
@Override
public String getDailyWorkout() {
return "Run a hard 5k";
}
…
}
www.luv2code.com
Why Spring Configuration with Annotations?
www.luv2code.com
Scanning for Component Classes
• Spring will scan your Java classes for special annotations
www.luv2code.com
Development Process
Step-
1. Enable component scanning in Spring config file
By-S
tep
www.luv2code.com
Step 1: Enable component scanning in Spring config file
<beans … >
</beans>
www.luv2code.com
Step 2: Add the @Component Annotation to your Java classes
@Component("thatSillyCoach")
public class TennisCoach implements Coach {
@Override
public String getDailyWorkout() {
return "Practice your backhand volley";
}
www.luv2code.com
Step 3: Retrieve bean from Spring container
www.luv2code.com