Meaningless Drivel is fun!
The moose likes Spring and the fly likes Default Spring Autowiring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Default Spring Autowiring " Watch "Default Spring Autowiring " New topic

Default Spring Autowiring

Jayesh Pokar

Joined: Apr 26, 2011
Posts: 10

I am new to Spring framework......

I want to know by default which auto-wiring way will be used to inject properties value to the class.

As I read I came to know that there is no default autowiring available, so how it is getting autowired in the below case where I didn't mention anything for autowiring.

beans.xml file

<bean id="javaLanguage" class="LanguageBean">
<property name="languageName" value="Java"/>

public class LanguageBean implements BeanNameAware
private String languageName;
private String beanName;

setter & getter are there.


When I run the Program i got the value for property name languageName, So by which mechanism it get injected the value, how it came to know to use setter injection and not constructor injection?
Also is Dependency Injection same as Autowiring?
Please help me.

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Using the <property name=""> tag means call the set method using the name attribute. So <property name="hello" value="bonjour"/>

means call the setHello method passing in the String "bonjour"

For a constructor you use the <constructor-arg value="bonjour" passes in the String "bonjour" to a constructor.

Hope that helps


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Default Spring Autowiring
It's not a secret anymore!