添加@Slf4j后Eclipse断点报错但仍可用的原因与修复
Spring Boot主类添加@Slf4j后Eclipse断点报错但功能正常
报错信息
Eclipse弹出以下断点安装失败提示:
### Java Breakpoint Unable to install breakpoints in xxx.xxx...$$EnhancerBySpringxxx due to missing line number attributes. Modify compiler options to generate line number attributes. Reason: Absent Line Number Information [ ] Don't tell me again [OK]
注:实际断点仍能正常触发并工作。
背景
- 为通过AspectJ实现日志记录,给Spring Boot主类添加了
@Slf4j注解,此前项目运行无异常 - 同类POC(概念验证)示例在Spring Boot环境中可正常运行,但当前项目无法轻易重构
相关代码
主类代码
@SpringBootApplication @Import({xxx.class}) @ComponentScan(basePackages = { /* ... */ } ) // 添加该注解后出现问题 @Slf4j public class MainApp {}
AspectJ日志切面代码
@Aspect @Component public class LoggingAspect { private Logger logger = LoggerFactory.getLogger(LoggingAspect.class); // ... @Around("@annotation(LogExecutionTime)") public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable { long startTime = System.currentTimeMillis(); Object proceed = joinPoint.proceed(); long endTime = System.currentTimeMillis(); // 断点设置在此处的日志代码行 logger.info(joinPoint.getSignature() + " executed in " + (endTime - startTime) + "ms"); return proceed; } // ... }
已尝试的无效操作
- 重启Eclipse及操作系统
- 删除并重新添加断点
- 执行
mvn clean compile和/或mvn install重建项目 - 重新配置JDK、Maven及其相关设置
- 重复执行
mvn clean compile和/或mvn install - 验证POC示例可正常运行,确认基础概念无误
- 撤销并重新添加
@Slf4j注解,排查缓存问题
需求
寻求该报错的根本原因及实际可行的修复方案,要求不能忽略、隐藏或抑制该问题。
内容的提问来源于stack exchange,提问作者Zach
相关产品推荐
相关产品推荐

