Announcement Announcement Module
Collapse

JavaConfig forum decommissioned in favor of Core Container

As described at

http://static.springsource.org/sprin...fig/README.TXT

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

http://static.springsource.org/sprin...tml#beans-java

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at

http://forum.springsource.org/forumdisplay.php?f=26
See more
See less
Application Context set up for Java Inheritance Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Application Context set up for Java Inheritance

    Hi,

    Is it possible to configure inheritance in java in my applicationContext.xml

    Here is my java classes:

    Code:
    public class Bicycle
    {
         private String name;
         public getName(){return name;}
         public setName(String n){name=n;}
    }
    
    public class MountainBike extends Bicycle
    {
    }
    
    public class KidBike extends Bicycle
    {
    }
    Can someone show me how can I configure my application context to map this?

    I would like to set the property name as bean property.
    Code:
    <bean id="name" class="Bicycle">
    	<property name="name" value="ABC"/>
    </bean>

    Thanks,

  • #2
    It's not really clear what's not working for you. If you'd like to create a bean of type MountainBike, with the 'name' property set to "ABC", it's no problem:

    Here's how it would look with class Bicycle:

    Code:
    <bean id="bike" class="Bicycle">
    	<property name="name" value="ABC"/>
    </bean>
    And in the case of MountainBike:

    Code:
    <bean id="bike" class="MountainBike">
    	<property name="name" value="ABC"/>
    </bean>

    Comment

    Working...
    X