Inheritance of spring bean and Java Bean

Source: Internet
Author: User

Spring also has an abstract bean. You only need to set the abstract attribute to true in the configuration file. It does not configure the class attribute because it will not be instantiated. When the bean of another spring inherits the abstract bean, You need to configure its parent attribute. If the parent bean is configured with a class, the sub-bean can be configured or not. If this parameter is not set, it is instantiated Based on the parent class. If it is configured, It is instantiated based on its own configuration. Some of its sub-bean parameters or methods can inherit from the parent bean, but some cannot. These are also determined by some configuration attributes in the configuration file. For details, refer to attribute configuration.

The inheritance of spring bean differs from that of Java Bean in the following ways:

1. Spring bean and parent can be of different types, but the child of Java inherits the parent's enhancement and characterization.

2. Spring bean integration is actually the relationship between instances (Object-Oriented). It is not a continuation of parameter values, but a relationship between classes in Java. Is the continuation of methods and properties.

3,SpringNeutronBeanCannot be a parentBeanUse, does not have polymorphism; andJavaSubclass instances in can be used as parent class instances.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.