NetBeans8.2 IDE修改Java class默认注释

导语:

          NetBeans现在已经运用的越来越广泛,最新的版本是8.2版本,其中的template功能也是逐渐完善,其中就包含了头部注释的功能,默认内容如下:

/*
 * 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 InheritedClass;

/**
 *
 * @author Arthur
 */
public class InheritedClass {
    
}

    本教程修改的是头部和中间的注释内容。

一、仅修改本工程的注释内容

  1. 修改之后,只有当前工程的class中的注释发生改变,不影响新创建的类和已经创建过的类
  2. 修改方法:右键当前工程名 --> properties --> License Headers --> 选择use project location,在下面的license header中进行编辑即可

二、修改默认模板

  1. 修改之后所有java工程都会改变,包括了用户名和中部注释的修改
  2. 选择上图(注意是上图),选择Use global license 选择Edit global license,弹出如下对话框,选择Defdault License,open in editor就可以修改全局注释模板

       3. 中部注释修改方法:Tool --> templates --> 展开java --> 选择java class,选择open in editor

         原始文件内容如下:

<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "${project.licensePath}">

<#if package?? && package != "">
package ${package};

</#if>
/**
 * @author  ${user}
 * 
 */
public class ${name} {

}

将 下面内容删除,则不会出现头部注释

<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "${project.licensePath}">

<#if package?? && package != "">

还可以增加创建时间等变量,具体参考 NetBeans中部注释修改

4.修改用户名,即@author的内容

在上图中点击settings,原始内容如下:

#
# Here, or in other properties files in this directory, you can define
# various properties that you want to make available to the template
# processor while creating various templates.
#

# uncomment the next line and specify your user name to be used in new templates
# user=Your name <your.name at your.org>

将user前面的#去掉,在your name位置添加上您的姓名,后面添加您的个人主页,如果没有就删掉,即可

欢迎评论和留言!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值