代码生成插件CodeMaker
IDEA强大的 LiveTemplates
自定义Templates模板
快速打印当前上下文信息
触发单词单词:logiv
模板定义:log.info("$EXPR_COPY$ = {}", $EXPR$);
模板变量值:EXPR:variableOfType(""),EXPR_COPY:escapeString(EXPR)
快速定义final私有变量
触发单词单词:psf
模板定义:private final static String $varName$ = "$var$";
IDEA自带Templates模板
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#set($name = ${NAME})
#if (${NAME} && $name.endsWith("Controller"))
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
#end
#if (${NAME} && $name.endsWith("Service"))
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
#end
#if (${NAME} && $name.endsWith("Dao"))
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
#end
#parse("File Header.java")
/**
* @author ${USER}
* @date ${YEAR}-${MONTH}-${DAY}
*/
#if (${NAME} && $name.endsWith("Controller"))
@RestController
@RequestMapping("/")
#end
#if (${NAME} && ($name.endsWith("Service") || $name.endsWith("Dao")))
@Service
#end
public class ${NAME} #if (${NAME} && $name.endsWith("Service"))#end {
#if (${NAME} && $name.endsWith("Controller"))
@RequestMapping(value = "/demo", method = RequestMethod.GET)
public String demo() {
return "Demo + ${NAME}";
}
#end
}