Search code examples
spring-mvchibernate-annotationsspring-annotations

which annotations comes under <context:component-scan>?


does it scan for controller,service,dao,autowired annotations only? what is it's impact on RequestMapping, ResponseBody and other hibernate-annotations line Id,Table etc. If in my project i am not using any controller,service,dao,autowired annotations and using only RequestMapping,ResponseBody and Hibernate-annotations then is required in dispatcher xml or not.?


Solution

  • For your scenario, the answer is NO. It's sample. Since you do not add any Spring annotation on Class, it means the bean is not managed by Spring. So the Spring can not do anything on it. It's the same to the hibernate annotation.

    And for Context:component-scan, I recommend you to open the context schema: http://www.springframework.org/schema/context/spring-context-3.0.xsd, it has description on it. Also note, for all of this kinds of config, please open the schema and check the description, it's very clear.