Professional Documents
Culture Documents
1 Introduction
Autowiring is method of creating an instance of an object and "by concept" injecting that instance on a
specific class that uses it.
By that, therefore creates a "wiring" of an instance to a class that will use it’s attributes. In Spring, when the
application server
initialize the context, it creates a stack/heaps of objects in it’s JVM container. This objects are available for
consumption at any
given time as long as the application is running (runtime). Now once these objects are ready, they can now
be injected to different
classes that belongs on the same application context. In a standard Java application, we can use the
ClassPathXmlAppli
cationContext class to create instances of the beans on the IoC container (JVM), making them available to
be injected Or
In this example, I will show you how a bean is wired by create the classes (beans) inside the
applicationContext.xml
and using ClassPathXmlApplicationContext to create the object instance that will be used by our
AppMain.java class.
Create the Java project. I would suggest using Maven so that we can easily get the dependency if needed.