UrbanPro

Learn Spring from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is autowire in spring and why it is needed?

Asked by Last Modified  

7 Answers

Learn Spring

Follow 0
Answer

Please enter your answer

Software Engineer

Brilliant feature of spring is dependency injection as for example if i have two component class say A and B. A want to call the method of B (say m1 method of B).In Class A I need to create the object of B like B b=new B(); then b.m1() i need to call,but problem with this statement my Class A is tightly...
read more
Brilliant feature of spring is dependency injection as for example if i have two component class say A and B. A want to call the method of B (say m1 method of B).In Class A I need to create the object of B like B b=new B(); then b.m1() i need to call,but problem with this statement my Class A is tightly couple with B. In order to resolve this issue there is a dependency injection concept where automatically B object will be created and injected into A class using either setter injection or constructor injection. This injection(setter and constructor) in spring is done through IOC container of Spring,but how spring will know which object (Dependency Class ) you want to inject in which class(Target Class). In our case we want to inject B class Object in A class. For that there is a two tag property tag or constructor tag to tell to spring which object I want to inject. i.e., i need to write some extra configuration to inject B class object i.e property or constructor tag. Without writing this extra cfg also I can tell to spring which object I want to inject and spring will be intelligent enough to identify which Dependency object I want to inject in Target Class. The concept which allows to do so is Autowire. read less
Comments

Java Trainer

The Spring container can autowire relationships between collaborating beans without using constructor-arg and property elements which helps cut down on the amount of XML configuration you write for a big Spring based application. In my view, Spring ‘auto-wiring’ make development faster with great costs...
read more
The Spring container can autowire relationships between collaborating beans without using constructor-arg and property elements which helps cut down on the amount of XML configuration you write for a big Spring based application. In my view, Spring ‘auto-wiring’ make development faster with great costs – it added complexity for the entire bean configuration file, and you don’t even know which bean will auto wired in which bean. In practice, I rather wire it manually, it is always clean and work perfectly, or better uses @Autowired annotation, which is more flexible and recommended. read less
Comments

Instead of creating an object instance of some other class, If you give that class name with auto wired you can access that class methods etc. This comes under dependency injection in the springs. By using auto wired we can achieve this dependency injection.
Comments

Autowiring is used to reduce the code in spring configuration file without writing property element and constructor element. It has five modes - no, by Name, by Type, constructor and auto detect
Comments

First, and most important - all Spring beans are managed - they "live" inside a container, called "application context". Second, each application has an entry point to that context. Web applications have a Servlet, JSF uses a el-resolver, etc. Also, there is a place where the application context is...
read more
First, and most important - all Spring beans are managed - they "live" inside a container, called "application context". Second, each application has an entry point to that context. Web applications have a Servlet, JSF uses a el-resolver, etc. Also, there is a place where the application context is bootstrapped and all beans - autowired. In web applications this can be a startup listener. Autowiring happens by placing an instance of one bean into the desired field in an instance of another bean. Both classes should be beans, i.e. they should be defined to live in the application context. What is "living" in the application context? This means that the context instantiates the objects, not you. I.e. - you never make new UserServiceImpl() - the container finds each injection point and sets an instance there. read less
Comments

B.Tech

It is a spring concept by which we are archiving loose coupling in our program. It gives us the flexibility to instantiate the object using XML (so need to mention Object class name) at the time of coding.
Comments

Trainer

Autowiring is used to inject a class into other class like a new object.
Comments

View 5 more Answers

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Recommended Articles

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Looking for Spring Training?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Spring Classes?

The best tutors for Spring Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Spring with the Best Tutors

The best Tutors for Spring Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more