[英]Auto document time of creation of new Java class
When I create a new Java file in NetBeans, I get auto documentation for @author
.当我在 NetBeans 中创建一个新的 Java 文件时,我会得到@author
自动文档。 How can I setup NetBeans that is also documents the time and date of creation of the class?如何设置 NetBeans,同时记录类的创建时间和日期?
I know NetBeans can do it as I get the time and date of creation in new CSS files by default.我知道 NetBeans 可以做到这一点,因为我默认获取新 CSS 文件中的创建时间和日期。
You can change the template files in Netbeans.您可以在 Netbeans 中更改模板文件。 Go to Tools|Templates
.转到Tools|Templates
。 From the available templates, find the one you want to change, let's say Java|Java Class
, then select Open in Editor
从可用模板中,找到您要更改的模板,例如Java|Java Class
,然后选择Open in Editor
Then goto to FaqTemplateVariables for list of available template variables.然后转到FaqTemplateVariables以获取可用模板变量的列表。 In your case, you're looking for ${date}
and {$time}
在您的情况下,您正在寻找${date}
和{$time}
Then you modify the template the way want, for example...然后你以想要的方式修改模板,例如......
<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "${project.licensePath}">
<#if package?? && package != "">
package ${package};
</#if>
/**
*
* @author ${user}
* ${date} ${time}
*/
public class ${name} {
}
Then simple create a new "Java Class" - File|New File|Java|Class
and it should then generate a file similar to this...然后简单地创建一个新的“Java 类” - File|New File|Java|Class
然后它应该生成一个类似于这个的文件......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package my.awesome.library;
/**
*
* @author noob
* 25/06/2017 3:19:39 PM
*/
public class Test {
}
Now, you'll probably have to go through a number of the other templates and update them, but that gives you a place to start现在,您可能需要浏览许多其他模板并更新它们,但这为您提供了一个开始
@MadProgrammer answered well. @MadProgrammer 回答得很好。 Just in case as an addition to this answer.以防万一作为这个答案的补充。 U can optionally add properties in the User.properties
file which is read by the various templates in the Tools -> Templated ->* configs
.您可以选择在User.properties
文件中添加属性,该文件由Tools -> Templated ->* configs
的各种模板读取。 So if u want to add version
to your Java classes
.因此,如果您想将version
添加到您的 Java classes
。 you can define the @version
in the Java class template and then define the property in the User.properties file as in the following您可以在 Java 类模板中定义@version
,然后在 User.properties 文件中定义属性,如下所示
In Your Java class template在您的 Java 类模板中
....
/**
* ${date} ${time}
* ${version}
* ...other
*/
U can then set these properties in the User.properties
file as然后你可以在User.properties
文件中将这些属性设置为
version=1.0.0
etc等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.