IDEA已经用了很长时间,经常在切换版本或重装后做一些配置,现在记录下认为比较实用的配置。
文中使用的IDEA2019.2
目录
安装插件
JUnitGenerator V2.0
CodeGlance
Lombok
Maven Helper
Rainbow Brackets
Alibaba Java Coding Guidelines
修改快捷键
-
增加字段注释
用于增加字段注释 Alt+D
-
取消idea双击shift时出现的全局搜索
https://blog.csdn.net/hxy199421/article/details/83030603
CTRL+shift +A
-
增加类注释
/**
*
* @description: ${description}
*
* @author: zhangzb10
*
* @create: ${YEAR}-${MONTH}-${DAY} ${HOUR}:${MINUTE}
**/
-
增加方法注释
**
* @description $description$
* @author zhangzb10
* @create $date$ $time$
*/
使用时在方法上输入 "/fun" 然后按tab间即可
-
增加获取当前日期和时间的快捷操作
$date$ $time$
使用时输入 "dt" 然后按tab
-
自动生成测试类的插件
JUnitGenerator V2.0
${SOURCEPATH}/../../test/java/${PACKAGE}/${FILENAME}
########################################################################################
##
## Available variables:
## $entryList.methodList - List of method composites
## $entryList.privateMethodList - List of private method composites
## $entryList.fieldList - ArrayList of class scope field names
## $entryList.className - class name
## $entryList.packageName - package name
## $today - Todays date in MM/dd/yyyy format
##
## MethodComposite variables:
## $method.name - Method Name
## $method.signature - Full method signature in String form
## $method.reflectionCode - list of strings representing commented out reflection code to access method (Private Methods)
## $method.paramNames - List of Strings representing the method's parameters' names
## $method.paramClasses - List of Strings representing the method's parameters' classes
##
## You can configure the output class name using "testClass" variable below.
## Here are some examples:
## Test${entry.ClassName} - will produce TestSomeClass
## ${entry.className}Test - will produce SomeClassTest
##
########################################################################################
##
#macro (cap $strIn)$strIn.valueOf($strIn.charAt(0)).toUpperCase()$strIn.substring(1)#end
## Iterate through the list and generate testcase for every entry.
#foreach ($entry in $entryList)
#set( $testClass="${entry.className}Test")
##
package $entry.packageName;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.junit4.SpringRunner;
/**
* ${entry.className} Tester.
*
* @author zhangzb10
* @version 1.0
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class $testClass {
#foreach($method in $entry.methodList)
@Test
public void test#cap(${method.name})() throws Exception {
}
#end
#foreach($method in $entry.privateMethodList)
@Test
public void test#cap(${method.name})() throws Exception {
#foreach($string in $method.reflectionCode)
$string
#end
}
#end
}
#end