• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ram Narainan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic