标签:创建时间 作者 tab 程序 pac ted which 自动注入 Edito
问题:创建类或接口时,要添加自定义的默认注释,比如版本,时间等。每个类修改显然不符合程序员的思路,有没有办法通过定义模板来实现?
Idea可听过创建类模板来实现。
功能路径:Setting -> Editor -> File and Code Template -> Class 修改,右侧文件内容
${}变量标识变量注入
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")
package ${PACKAGE_NAME}; // 解决package
#end
#parse("File Header.java")
// 默认导入lombok,方便日志打印
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @Title: ${NAME} // 默认是类名称
* @Description: // 类实现的介绍
* @author: libo // 作者
* @date: ${DATE} ${TIME} // 创建时间,${DATE} 自动注入系统日期,${TIME}自动注入当天时间,分钟
* @Version: 1.0 //版本
*/
@Slf4j
public class ${NAME} {
}
${PACKAGE_NAME} | name of the package in which the new class is created |
${NAME} | name of the new class specified by you in the Create New Class dialog |
${USER} | current user system login name |
${DATE} | current system date |
${TIME} | current system time |
${YEAR} | current year |
${MONTH} | current month |
${MONTH_NAME_SHORT} | first 3 letters of the current month name. Example: Jan, Feb, etc. |
${MONTH_NAME_FULL} | full name of the current month. Example: January, February, etc. |
${DAY} | current day of the month |
${HOUR} | current hour |
${MINUTE} | current minute |
${PROJECT_NAME} | the name of the current project |
新建一个类,Test
通过定义模板,可以完全自定义自己的类注释
标签:创建时间 作者 tab 程序 pac ted which 自动注入 Edito
原文地址:https://www.cnblogs.com/jason0529/p/13606595.html