1. 文件头注释设置
1.1 配置路径
File | Settings | Editor | File and Code Templates
1.2 配置选项
Includes --> File Header
1.3 配置内容
/** TODO <p> desc </p> @author: #if($Author_Name !="") ${Author_Name} #else ${USER} #end @date: ${DATE} ${TIME} */
2. Copyright (版权信息)设置
2.1 Scopes配置路径
File | Settings | Appearance & Behavior | Scopes
2.2 Scopes配置选项
Add Scope --> Shared
![](https://i-blog.csdnimg.cn/blog_migrate/c8b2c6d78023a504d4e1b97a55b96c6a.jpeg)
2.3 Scopes配置内容
![](https://i-blog.csdnimg.cn/blog_migrate/4c72f84b76b3748a0bda912be8acc25a.jpeg)
2.4 Copyright配置路径
File | Settings | Editor | Copyright | Copyright Profiles
2.5 Copyright配置选项
Add Copyright Profile
![](https://i-blog.csdnimg.cn/blog_migrate/4b8f11da35092f4dc6515604bf198104.jpeg)
2.6 Copyright配置内容
![](https://i-blog.csdnimg.cn/blog_migrate/31441d0ce3c05841ab8d226050894453.jpeg)
#set($copyrightBegin =${today.year})
#set($copyrightEnd =${today.year}+5)
Copyright (c) ${copyrightBegin}-${copyrightEnd} huangyuxi.com Authors. All Rights Reserved.
@Project: $project.name
@Module: $module.name
@Date: $today.format("yyyy-MM-dd 'T' HH:mm:ss")
2.7 Scope 与Copyright关联配置
![](https://i-blog.csdnimg.cn/blog_migrate/50044848326061cb2a779d1c799cc670.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/bf02e9d5f7677cd98b4c7e7fdd0f57ce.jpeg)
3. Method头注释设置
3.1 配置路径
File | Settings | Editor | Live Templates
3.2 配置选项
Add --> Templates Group
![]()
我这里命名为
hyx-group
,快捷键为mc
模板内容不太好编辑,请将3.3配置内容复制进来再编辑修改,去掉第一行的/*
模板中的变量如图设置
其中param 内容如下:
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {if(params[i] == '') return result;if(i==0) result += '\\n'; result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n' : '')}; return result", methodParameters())
3.3 配置内容
/**
* $method$ //TODO
* $param$
* @return $return$ //TODO
* @author $user$
* @date $date$ $time$
**/
3.4 快速加入函数头注释
在一个函数上方输入 /*mc
,然后按 tab
键自动补全注释