Naming rules that should be paid attention to when using spring to inject JavaBean

Source: Internet
Author: User

Generally, when using spring to inject JavaBean, public void setuerdao (userdao) is used ).

Then, you can go to <property name = "uerdao"> <ref local = "userdao"/>.

The first parameter is the name of setxxx. The following figure shows the DaO name configured in spring. If your Dao name is userdao1. In your <property name = "uerdao"> <ref local = "userdao1"/>.

There is also an error caused by nonstandard naming, such as: public void setdbbasedao (dbbasedao Dao ).

In this example, the lower-case letters in front of Dao are used according to the previous configuration. This time will not work.

<Property name = "dbbasedao"> <ref local = "dbbasedao"/>.

At this time, you will still encounter problems according to the previous configuration method. Here we need to configure it like this

<Property name = "dbbasedao"> <ref local = "dbbasedao"/>.

Now, the dB of dbbasedao is used as a lowercase letter. The dB is relative to the user of Example 1, and then the basedao is relative to the DAO of Example 1. In this way, it is passed.

 

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.