Spring injection static member variable hint invalid setter method

Source: Internet
Author: User

Really is not careful enough Ah, was pit one night.

An extremely simple applet, but requires an XML file configuration to inject a value, and the only attribute to be injected is the static member variable in the class:

The Get and set methods are then automatically generated as follows: The pit began ...

 Public class food{   privatestatic  String  desc;      Public Static String GetDesc () {       return  desc;  }       Public Static void Setdesc (String desc) {      = desc;  }}

Then the XML is configured as follows:

<id= "Food"  class= "xxxk." Food ">        <name=" desc "  value=" Foods "  /></bean>

Then start the error that the set method cannot be found ... Repeatedly compares the name of the set method without any exception. And then one night it was scrapped ...

Finally found that the auto-generated method will be with the static modifier, and spring's set method can not be static, followed by the source to find, although the various values and names can be obtained, but one of the resolveddescriptor is not available.

Remove the static modifier in front of the set method.

Spring injection static member variable hint invalid setter method

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.