Reputation: 56
Where can I see the source code behind the @Service
or org.springframework.stereotype.Service
in the Spring framework?
Upvotes: 0
Views: 330
Reputation: 1
For Example if you want to find the logic for @Autowired in Spring Boot.
Right Click on the pom.xml, Select Maven->Download Resources.
Now in the external libraries the @Autowired annotation is defined in the org.springframework.beans.factory.annotation package. The source file is typically named Autowired.java.
The logic for this annotation is found in the same folder.
Look into classes like AutowiredAnnotationBeanPostProcessor and DefaultListableBeanFactory. These classes are part of the Spring container and are involved in the process of detecting and injecting dependencies.
Upvotes: 0
Reputation: 202
If you are using IDE, to check @Service
implementation you can press Ctrl
and click on this annotation. org.springframework.stereotype.Service
interface will be opened in this case.
Upvotes: 0
Reputation: 1585
Annotations themselves do not carry implementation logic, just some simple attributes. The framework (Spring in our case) just checks for the existence of annotations (i.e instances of an annotation class like Service
) on our classes and then acts accordingly. For example, if it sees a Service
present, it will instantiate our class as a bean and manage that bean.
Upvotes: 1