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 框架
- 单例模式/枚举单例生成
- 读取文件
- 常量
- 追踪
- 格式化字符串
- 评论代码审查
- 字符串格式
- 最后尝试锁定
- 消息格式 i18n 和日志
- 平等建设者
- 哈希码生成器
- Spring 对象注入
- 创建文件输出流
推荐答案
如果需要,以下代码模板将创建一个记录器并创建正确的导入.
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);
来源.
七月
${:import(java.util.logging.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class.getName());
这篇关于寻求有用的 Eclipse Java 代码模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:寻求有用的 Eclipse Java 代码模板


基础教程推荐
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 降序排序:Java Map 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01