寻求有用的Eclipse Java代码模板 [英] Seeking useful Eclipse Java code templates
本文介绍了寻求有用的Eclipse Java代码模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您可以通过
窗口>首选项> Java>编辑器>模板
例如
sysout
扩展为:
System.out.println(${word_selection}${});${cursor}
您可以通过键入sysout
,然后按CTRL+SPACE
You can activate this by typing sysout
followed by CTRL+SPACE
您当前使用哪些有用的Java代码模板?包括它的名称和描述,以及它为什么很棒.
What useful Java code templates do you currently use? Include the name and description of it and why it's awesome.
我正在寻找模板的原始/新颖用法,而不是内置的现有功能.
I am looking for an original/novel use of a template rather than a built-in existing feature.
- 创建Log4J记录器
- 从显示中获取swt颜色
- Syncexec-Eclipse框架
- 单例模式/枚举单例生成
- 读取文件
- const
- 淘汰赛
- 格式化字符串
- 评论代码审核
- 字符串格式
- 尝试最终锁定
- 邮件格式i18n和日志
- Equalsbuilder
- Hashcodebuilder
- 弹簧对象注入
- 创建FileOutputStream
- Create Log4J logger
- Get swt color from display
- Syncexec - Eclipse Framework
- Singleton Pattern/Enum Singleton Generation
- Readfile
- Const
- Traceout
- Format String
- Comment Code Review
- String format
- Try Finally Lock
- Message Format i18n and log
- Equalsbuilder
- Hashcodebuilder
- Spring Object Injection
- Create FileOutputStream
推荐答案
以下代码模板将创建一个记录器,并在需要时创建正确的导入.
The following code templates will both create a logger and create the right imports, if needed.
SLF4J
${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)}
private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class);
Log4J 2
${:import(org.apache.logging.log4j.LogManager,org.apache.logging.log4j.Logger)}
private static final Logger LOG = LogManager.getLogger(${enclosing_type}.class);
Log4J
${:import(org.apache.log4j.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class);
来源.
7月
${:import(java.util.logging.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class.getName());
这篇关于寻求有用的Eclipse Java代码模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文