IDEA-live-template 一些好用的 IDEA 模板代码汇集
mybatis
<if>
标签
<if test="judgeFullName != null ">
AND judge_full_name = #{judgeFullName}
</if>
输入代码 ,使用 Ctrl + Alt + J
选中,选择 IFA
<if test="$SELECTION$ != null ">
AND $VAR1$ $END$ = #{$SELECTION$}
</if>
<template name="IF" value="<if test="$SELECTION$ != null "> AND $VAR1$ $END$ = #{$SELECTION$} </if>" description="if" toReformat="true" toShortenFQNames="true">
<variable name="VAR1" expression="snakeCase(String)" defaultValue="$SELECTION$" alwaysStopAt="true" />
<context>
<option name="SQL" value="true" />
</context>
</template>
mybatis
<foreach>
标签
<foreach item="item" collection="List" separator="," open="(" close=")" index="">
#{item}
</foreach>
输入代码,使用 Ctrl + Alt + J
选中,选择 FI
<foreach item="item" collection="$SELECTION$" separator="," open="(" close=")" index="">
#{item}
</foreach>
<template name="FI" value="<foreach item="item" collection="$SELECTION$" separator="," open="(" close=")" index=""> #{item} </foreach>" description="for earch in" toReformat="true" toShortenFQNames="true">
<context>
<option name="SQL" value="true" />
</context>
</template>
MYSQL
LIKE CONCAT()
语句补全
LIKE CONCAT('%',#{judge_full_name} ,'%' )
输入代码,使用 Ctrl + Alt + J
选中,选择 LikeC
LIKE CONCAT('%',#{$SELECTION$} ,'%' )
<template name="LikeC" value="LIKE CONCAT('%',#{$SELECTION$} ,'%' )" description="Like Concat" toReformat="true" toShortenFQNames="true">
<context>
<option name="SQL" value="true" />
</context>
</template>
spring
@Transactional(rollbackFor = Exception.class)
语句补全
@Transactional(rollbackFor = Exception.class)
输入@TS
,然后 Tab
@Transactional(rollbackFor = Exception.class $END$)
<template name="@TS" value=" @Transactional(rollbackFor = Exception.class $END$)" description="@Transactional" toReformat="false" toShortenFQNames="true" useStaticImport="true">
<context>
<option name="JAVA_CODE" value="true" />
</context>
</template>
spring
@Autowired
语句补全
@Autowired
private TestService testService;
复制类名,输入aut
,然后 Tab
@Autowired
private $VAR$ $VAR_HUMP$$END$;
<template name="aut" value="@Autowired private $VAR$ $VAR_HUMP$$END$;" description="Autowired" toReformat="false" toShortenFQNames="true">
<variable name="VAR" expression="clipboard()" defaultValue="" alwaysStopAt="true" />
<variable name="VAR_HUMP" expression="camelCase(clipboard())" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="true" />
</context>
</template>
根据剪贴板生成实体String
字段
/**
*
*/
private String test;
输入ps
,然后 Tab
/**
* $DESC$
*/
private String $VAR$$END$;
<template name="ps" value="/** * $DESC$ */ private String $VAR$$END$;" description="private String" toReformat="false" toShortenFQNames="true">
<variable name="DESC" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="VAR" expression="clipboard()" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="true" />
</context>
</template>
根据剪贴板生成实体String
字段
/**
*
*/
private Integer test;
输入pi
,然后 Tab
/**
* $DESC$
*/
private Integer $VAR$$END$;
<template name="pi" value="/** * $DESC$ */ private Integer $VAR$$END$;" description="private Integer" toReformat="false" toShortenFQNames="true">
<variable name="DESC" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="VAR" expression="clipboard()" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="true" />
</context>
</template>