JavaBeans explained

How does Spring know about the setter method? How to inject the value into it? In fact, the method name must follow the convention, and the method name injected by the setter must follow the "JavaBean getter/setter method naming convention"

JavaBean: is essentially a POJO class, but has the following limitations:
         The class must have a public no-argument constructor, such as public HelloImpl4() {};
         The attribute is private access level, public is not recommended, such as private String message;
         Properties are accessed through a set of setter (modifier) ​​and getter (accessor) methods when necessary;
         The setter method starts with "set", followed by the property name with the first letter capitalized, such as "setMessage", a simple property generally has only one method parameter, and the method return value is usually "void";
         The getter method, the general attribute starts with "get", and the boolean type generally starts with "is", followed by the attribute name with capital letters, such as "getMessage", "isOk";
         There are also some other special cases, such as properties that start with two consecutive uppercase letters, such as "URL", then the setter/getter methods are: "setURL" and "getURL". For other special cases, please refer to the "Java Bean" naming convention.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326863998&siteId=291194637