Set class annotation template
1.选择File–>Settings–>Editor–>File and Code Templates–>Includes–>File Header.
2. In the blank space on the right, you can write your own template. Note that Scheme is the effective scope of the template. The optional variables are introduced in the description. ).
/**
* @Auther: ${USER}
* @Date: ${DATE} ${HOUR}:${MINUTE}
* @Description:
*/
- 1
- 2
- 3
- 4
- 5
3. After the setting is completed, the annotation will be automatically generated when the class is created, and the effect is as follows.
Set method annotation template
Idea does not have a place where you can directly set the method annotation template. You can use Live Templates for basic implementation. The steps are as follows.
1. Select File–>Settings–>Editor–>Live Templates, first select the green plus sign on the right to create a new template group of your own, named myGroup as shown in the figure.
2. Select the created group and select the green plus sign on the right to create a new template, as shown below.
3. Fill in Abbreviation (quick input), Description (description) and template content (the template in the figure is as follows)
/**
*
* 功能描述:
*
* @param: $param$
* @return: $return$
* @auther: $user$
* @date: $date$ $time$
*/
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
4. Click Define and check Java
5. Click Edit variables to edit variables, set as follows, click Ok->Apply to complete the settings.
6. Enter "/**", and then press the Tab key to generate a comment, as shown below. Note that this method has a disadvantage, it needs to be generated inside the method, otherwise @param is null.