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 代码模板
基础教程推荐
- 将 Windows 证书导入 Java 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
