For a new legacy application I have to use Latest Spring framework 3.x with Hibernate 3.x. Earlier I used Spring IoC with xml configuration. Now i would like to go for annotation based IoC.
Below link from rose india shows use annotation without xml file.
rose india
but i have found some other way of implementing in another site:
blog
I am confused here which way to implement IoC with latest technology.
Please refer some good site for sample. Also please share some sample code for IoC with annotation.
EDIT:
Spring reference document 3.x says use @Configuration or xml configuration i.e. with annotation <context:annotation-config/>. Which one is better to use? Why?
Your best bet is to start with the Spring 3.0 Documentation. If you already are familiar with Dependency Injection using xml configuration, take a look at Spring’s annotation support in
Section 3.9 Annotation-based container configuration. There should be plenty of details there to help get you started.If this is not a WebApp, and you need to load the
ApplicationContextyourself, you should take a look atSection 3.11 Java-based container configuration. This section details how you can create yourApplicationContextwith your xml configuration.I would recommend using the
@Autowiredannotations for wiring with@Componentannotation for defining beans within theApplicationContext, and use thescan(String)method provided by theAnnotationConfigApplicationContextto find all annotated components: