前言:持续更新与完善,记录本人开发中的常用方法与技巧~
1. 日志打印
import lombok.extern.slf4j.Slf4j;
@Slf4j
log.info("对象打印:{}",UserDTO);
2. 调试
(1)实现for循环的条件Debug,比如循环1000次,我想跳到第799次,可用此办法。
(2)评估表达式的使用(动态赋值调试)
第一步,无任何参数
第二步,给kmbm赋值130000
第三步,F8步过去查数据库,查看返回结果
如果你不动态给参数赋值的话,list接口肯定是查询的全部的
3.属性拷贝
import org.springframework.beans.BeanUtils;
BeanUtils.copyProperties(source,target);
4. 测试类
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
单元测试后续问题:
与websocket共用时冲突解决办法
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
mvn test跳过/不跳过配置位置
通过idea快捷生成测试类方法