Useful Java Code Templates in Eclipse
In Eclipse, you can create various Java code templates by:
Window > Preferences > Java > Editor > Templates
For example:
sysout expands to:
System.out.println(${word_selection}${});${cursor}
You can activate this code by typing sysout and then pressing CTRL SPACE.
What useful Java code templates are you currently using?
Please include a name and description of the template and why it’s great.
I'm looking for an original/novel use of the template rather than an existing feature built in.
We received the recommended template:
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);
JUL
${:import(java.util.logging.Logger)} private static final Logger LOG = Logger.getLogger(${enclosing_type}.class.getName());
The above is the detailed content of What Java Code Templates Do You Use in Eclipse That Go Beyond the Basics?. For more information, please follow other related articles on the PHP Chinese website!