首先确保IDEA中有Lombok插件
导入依赖:
<!--slf4j-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
<!--Lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
然后在服务层上添加@Slf4j
注解,在方法中就可以使用了
@Slf4j
@Service
public class PeriodServiceImpl implements PeriodService {
@Autowired
private PeriodMapper periodMapper;
@Override
public PageBean<Period> list(Integer pageNum, Integer pageSize, Date period, String notes) {
log.info("分页查询");
log.warn("分页查询");
log.error("分页查询");
return pb;
}
log有info、warn、error等类型