Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 915461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:53:28+00:00 2026-05-15T17:53:28+00:00

I am new to spring and trying to understand the functionality of the idref

  • 0

I am new to spring and trying to understand the functionality of the idref tag

My config file is pasted here:

<bean id="AudioSystembean" class="com.springexample.AudioSystem">
  <property name="price" value="200"/>
</bean>

<bean id="Vehicle1" class="com.SpringExample.Vehicle1">
  <property name="vehicleType" value="CAR" />
  <property name="audioSystem" >
    <idref bean = "AudioSystembean" /> 
  </property>
</bean>

When I am executing the code I am getting the error as : "BeanInstantiationException:Cannot convert type from java.lang.String to required type :com.SpringExampl.AudioSystem" [I dont remember the exact exception – I have the code at home]

If I use ref instead of idref it is working fine.

I tried google to understand about idref but could not get much information..

What am I doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:53:29+00:00Added an answer on May 15, 2026 at 5:53 pm

    In a Spring context, <idref> is used to pass the name of the referenced bean, rather than the bean itself (which is what <ref> does). So in your example:

    <property name="audioSystem" >
       <idref bean = "AudioSystembean" /> 
    </property>
    

    The audioSystem system property will be injected with the name of the AudioSystembean, i.e. the String “AudioSystembean”.

    This is not what you need here, though, you need the <ref> element, which passes a reference to the bean itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Spring Framework and trying to understand the functionality of formBackingObject
I'm new to Spring and trying to use the Spring Formatting SPI for UI
I m very new in spring batch project.I m trying to create a project
I'm trying to understand Spring 3.0 authentication. In the code below, why is user.getRole()
I'm trying to understand how the new try-with-resources statement works by recreating it using
I am new to JSF and Spring. I am trying to use Spring Security
I am trying to understand architecture of Spring MVC. However, I am completely confused
I am trying to understand programming logic behind the beans of Spring. In examples
I am brand new to C# (VS 2010) and I'm trying to understand how
Spent 2 days trying to understand how to enable Eclipse work with Spring Data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.