1.配置路徑:
一锣吼、首先我們來(lái)設(shè)置IDEA中類的模板:(IDEA中在創(chuàng)建類時(shí)會(huì)自動(dòng)給添加注釋)
1女嘲、File-->settings-->Editor-->File and Code Templates-->Files
首先來(lái)到配置界面我去找了翻譯片段
大致的意思如下:
這是一個(gè)
內(nèi)置模板
,每次創(chuàng)建新的Java類時(shí)都會(huì)使用它,方法是從一個(gè)項(xiàng)目視圖中的彈出菜單中選擇new | Java類| class角雷。模板是可編輯的
祸穷。除了Java表達(dá)式和注釋之外,您還可以使用預(yù)定義的變量(如下所示)勺三,然后將這些變量像宏一樣展開(kāi)為相應(yīng)的值雷滚。也可以以${}的格式指定任意數(shù)量的自定義變量。在這種情況下吗坚,在創(chuàng)建新文件之前揭措,將出現(xiàn)一個(gè)對(duì)話框,您可以在其中為所有自定義變量定義特定的值刻蚯。使用#parse指令幔欧,您可以通過(guò)在引號(hào)中指定所需模板的全名作為參數(shù),從include選項(xiàng)卡中包含模板抒倚。例如:#parse("File Header.java") 如果“NAME”不是系統(tǒng)能獲取的值 就需要彈出框手動(dòng)填寫就像對(duì)話框一樣
我們選擇Class文件(當(dāng)然你要設(shè)置接口拴孤,也可以選擇Interface文件)
1.上配置圖
2.代碼參考
/**
@ClassName -> ${NAME}
@Description
@Author 龍嶺
@Date ${DATE} ${TIME} ${DAY_NAME_FULL}
@Version 1.0
*/
那么這些變量是什么意思呢?我在下面依次闡述并且附帶示例
name of the package in which the new class is created 項(xiàng)目名 ${PACKAGE_NAME}
name of the new class specified by you in the Create New Class dialog 文件名 ${NAME}
current user system login name 系統(tǒng)用戶名 ${USER}
current system date ${DATE}
current system time 具體時(shí)間 ${TIME}
current year 年份 ${YEAR}
current month 二月 ${MONTH}
first 3 letters of the current month name. Example: Jan, Feb, etc.
${MONTH_NAME_SHORT}
full name of the current month. Example: January, February, etc. ${MONTH_NAME_FULL}
current day of the month ${DAY} 一個(gè)月的第幾天
current hour ${HOUR} 小時(shí)
current minute ${MINUTE} 分鐘
the name of the current project ${PROJECT_NAME} 項(xiàng)目名稱
image.png