aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Default Spring Autowiring " Watch "Default Spring Autowiring " New topic
Author

Default Spring Autowiring

Jayesh Pokar
Greenhorn

Joined: Apr 26, 2011
Posts: 10
Hi,

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"/>
</bean>

LanguageBean.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.

Thanks.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

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

Mark>


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default Spring Autowiring