0

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.?

RBP
  • 481
  • 1
  • 9
  • 29

2 Answers2

1

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.

OQJF
  • 1,350
  • 9
  • 12
  • means if i didn't add in XML .though RequestMapping,ResponseBody and other Hibernate annotations will work. It will not impact on it. right.? i just want to confirm again. – RBP Apr 24 '14 at 05:24
  • Actually, I think RequestMapping, ResponseBody don't work, the bean must be managed by Spring. Do you add xml config for these beans? – OQJF Apr 24 '14 at 05:25
  • Not yet .Actually I am moving my project from annotation to xml so I stucked there, If it will not work then i need to remove it.what about hibernate annotation.? will that work or not.? – RBP Apr 24 '14 at 05:33
  • For the hibernate annotation, the hibernate will scan the classpath to handle it, so it doesn't have impact on it. – OQJF Apr 25 '14 at 01:42
  • Why you use xml instead of annotation? Did you use @Configuration or just Controller and Repository like this? – OQJF Apr 25 '14 at 01:43
  • I am working on google web applicaton.I am using spring,hibernate annotations. In google application due to spring annotations, It is taking time to get response after deployment.It takes 5-10 min. So i wanted to remove annotations. Please take a look at https://developers.google.com/appengine/articles/spring_optimization. If hibernate annotations don't have any impact after removing component scan tag then It will be gr8. otherwise i need to create xml of tables also.But are you sure ? Because @Aeseir has given answer that it will not work if i removed component scan. – RBP Apr 28 '14 at 09:09
  • I have a test project which only has hibernate, jpa and derby db as dependencies, and the annotations work well. so is this more clear? – OQJF Apr 29 '14 at 06:44
  • yup.okie.I will check later. – RBP Apr 29 '14 at 07:00
0

No, it does a lot more than that.

For detailed description on component scanning please refer to these sections as starting point in reference page:

http://docs.spring.io/spring/docs/4.0.3.RELEASE/spring-framework-reference/htmlsingle/#beans-annotation-config

http://docs.spring.io/spring/docs/4.0.3.RELEASE/spring-framework-reference/htmlsingle/#beans-classpath-scanning

Aeseir
  • 7,754
  • 10
  • 58
  • 107