idea Live Templates

一、idea Live Templates

1.1、Java Group

1.1.1、fast

fast 

快速在类上添加注解

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@ToString(callSuper = true)

1.1.2、getThreadName

getThreadName


快速获取当前线程的名字


Thread.currentThread().getName()

1.1.3、info

info

快速打印log日志


log.info(" result:{}", result);

1.1.4、infoj

infoj

快速打印json日志

log.info(" result:{}", JSON.toJSONString(result));

1.1.5、infopj

infopj


快速打印Controller层的参数


log.info(" param:{}", JSON.toJSONString(param));

1.1.6、mainb

mainb

快速生成springboot主启动类的main方法

public static void main(String[] args) {
    SpringApplication.run(.class, args);
}

1.1.7、msb

msb

在Springboot的主启动类上快速添加注解


@MapperScan(basePackages = "org.star.mapper")
@SpringBootApplication

1.1.8、sdf

sdf

快速生成格式化日期

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

1.1.9、sst

sst

在Springboot的测试类上快速添加注解

@Slf4j
@SpringBootTest

1.1.10、tryc

tryc

快速生成try...catch代码块

try {
            
} catch (Exception e) {
    
}

1.1.11、trycf

trycf

快速生成try...catch...finally代码块


try {
                    
} catch (Exception e) {
    
} finally {
    
}

1.1.12、tryf

tryf

快速生成try...finally代码块

try {
                    
} finally {
    
}

1.1.13、threadfor40

threadfor10

快速生成10个线程

for (int i = 1; i <= 10; i++) {
    new Thread(() -> {

    }, String.valueOf(i)).start();
}

1.1.14、threadNew

threadNew

快速创建一个线程

new Thread(() -> {
	try {
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}, "线程名字").start();

1.1.15、threadSleepTimeUnit

threadSleepTimeUnit

线程快速休眠(单位:秒)

// 线程休眠(单位:秒)
try { TimeUnit.SECONDS.sleep(4); } catch (Exception e) {e.printStackTrace();}

1.1.16、noArgs

noArgs

快速打印无参构造方法被调用了

System.out.println("xxx's NoArgsConstructor was invoked!");

1.1.17、allArgs

allArgs

快速打印有参构造方法被调用了

System.out.println("xxx's AllArgsConstructor was invoked!");

1.1.18、initJVMParams

initJVMParams

快速打印jvm的配置信息

-Xms10m -Xmx10m -XX:+PrintGCDetails

1.1.19、lock.lock

lock.lock

快速生成JUC lock代码块

lock.lock();
try {
	// do your business...
} catch (Exception e) {
	e.printStackTrace();
} finally {
	lock.unlock();
}

allArgs

快速打印某个类的有参构造方法被调用了

System.out.println("xxx's all args constructor was called!");

1.1.20、threadFor40Group

threadFor40Group

快速生成一组同名的线程

new Thread(() -> {
	for (int i = 1; i <= 40; i++) {
		
	}
},"线程名字").start();

1.2、SQL Group

1.2.1、initsql

initsql
快速生成sql基本模板
drop database if exists 20231110_shiro;
create database 20231110_shiro;
use 20231110_shiro;
 
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
                         `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
                         `is_deleted` int NOT NULL DEFAULT 0 COMMENT '删除标识 0:未删除、1:已删除',
                         `create_time` datetime NOT NULL COMMENT '创建时间',
                         `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
                         `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名',
                         `age` int NULL DEFAULT NULL COMMENT '年龄',
                         `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
                         PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户表' ROW_FORMAT = DYNAMIC;

1.3、XML Group

1.3.1、webxml

webxml
快速生成web.xml中的基本配置
<!-- spring -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- spring mvc -->
<servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:dispatcherServlet.xml</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcherServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<!-- 全局乱码过滤器 -->
<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceRequestEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>forceResponseEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值