Simple Spring property injection and set property Injection

Source: Internet
Author: User

Simple Spring property injection and set property Injection

Property injection is an important feature in Spring. The following describes the specific operations of simple property injection and set property injection.

Steps:

① The property tag should be used for both simple property injection and set property injection.

② If it is a simple property injection, you can directly assign a value to the value of the property tag. We can leave the value type unspecified, and the framework will automatically identify it. Of course, we can also specify it, the specified format is java. lang. string (type to be written ). There are also two methods:

Method 1:

Method 2:

Value

③ If the set type is set, in addition to adding the property tag, the corresponding set type tag should also be added to the tag.

As follows:


The preceding method can be used to inject simple attributes and set type attributes.

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.