Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Default Spring Autowiring

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Get me the mayor's office! I need to tell him about this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic