I want to understand what is the exact meaning of term "autowiring" and AOP in Spring Framework.
-
`Autowired` - the injection of a singleton (by default) spring service. `Aspect Oriented Programming` well, there's more than a comment or an answer to it... – Daniel Apr 17 '16 at 20:20
2 Answers
From the official Spring Framework Reference:
The Spring container can autowire relationships between collaborating beans. You can allow Spring to resolve collaborators (other beans) automatically for your bean by inspecting the contents of the ApplicationContext.
Which basically means you can leave it up to the Spring Framework to initialize your beans and ensure they're there when you need them. For example, lets say I have a number of Thing
s in my app. Now, if I want to get all the Thing
s and have them placed in a List<Thing>
, in Spring (assuming I've configured it properly), I can simply use this code:
@Autowired
private List<Thing> things;
With no additional effort on my part I have the list I needed.
The question concerning Aspect Oriented Programming (AOP) as it relates to Spring would be quite a bit to put in a post. The simple explanation can be seen in the official Spring Framework Reference:
Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by providing another way of thinking about program structure. The key unit of modularity in OOP is the class, whereas in AOP the unit of modularity is the aspect. Aspects enable the modularization of concerns such as transaction management that cut across multiple types and objects. (Such concerns are often termed crosscutting concerns in AOP literature.)
One of the key components of Spring is the AOP framework. While the Spring IoC container does not depend on AOP, meaning you do not need to use AOP if you don’t want to, AOP complements Spring IoC to provide a very capable middleware solution.
That section is very detailed and worth a read if you're interested in AOP.

- 1
- 1

- 13,548
- 8
- 49
- 75
Autowiring is a mechanism of resolving dependencies in Spring IoC container, as per Spring Reference. So instead of directly specifying the dependency (in XML or in Java configuration), you can depend on container itself to provide you with candidate(s). Spring itself should abort if you find more than one matching dependency (unless you are looking for a collection of beans).

- 4,377
- 3
- 17
- 40