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 代码模板
基础教程推荐
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
