This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Spring and the fly likes referencing multiple objects from a Object.. How to set up reference in the beans.xml file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "referencing multiple objects from a Object.. How to set up reference in the beans.xml file" Watch "referencing multiple objects from a Object.. How to set up reference in the beans.xml file" New topic
Author

referencing multiple objects from a Object.. How to set up reference in the beans.xml file

Ram Narainan
Greenhorn

Joined: Feb 08, 2013
Posts: 1
Hi All,
Newbie here. Spending my first hour on the spring framework.
I was trying to add some references to some dependent classes to see how the framework works.
In my hello world object i would like to create a refernce to a car object and a engine object and a wheel object etc.. car engine and wheel objects are all contained in the hello world object.
Please feel to ask any information i may have left out.
appreciate any inputs.
Ram



<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="helloWorld" class="com.tutorialspoint.HelloWorld">
<property name="message" value="Hi there!"/>

<bean id="helloWorld" class="com.tutorialspoint.HelloWorld">
<property name="message" ref=”CarObj”/>

<bean id="CarObj" class="com.tutorialspoint.Car">
<ref id="wheel" class="com.tutorialspoint.Wheel">


</bean>



</beans>
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

first. because you put beans.xml makes me think you are not using up to date materials. It has been years and years since people used that file name.

2) a bean tag can have as many constructor-arg and property tags as needed between the opening and closing of the bean tag

Example



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: referencing multiple objects from a Object.. How to set up reference in the beans.xml file