Prompt invalid setter method, invalidsetter when spring injects static member variables
It was not very careful enough to get stuck for one night ..
It is an extremely simple small program, but a value needs to be injected through the xml file configuration. The unique attribute, especially the static member variable in the class, is used ..
And then the get and set methods are automatically generated...
Public class Food {private static String desc; public static String getDesc () {return desc;} public static void setDesc (String desc) {Food. desc = desc ;}}
Then, configure the following in xml:
<Bean id = "food" class = "xxxk. Food"> <property name = "desc" value = "food"/> </bean>
Then, the system will report an error where the set method cannot be found... compare the name of the set Method repeatedly, without any exception... then it will be decommissioned one night...
Finally, it is found that the automatically generated method will contain the static modifier, while the spring set method cannot be static. Let's look at the source code to find that although various values and names can be obtained, however, one of the resolvedDescriptor cannot be obtained.
Remove the static modifier before the set method ..