[英]How do I debug Spring annotations?
I have been using annotations on my Spring Boot project, and they are black boxes to me. 我一直在我的Spring Boot项目中使用注释,它们对我来说是黑匣子。 Unfortunately, I ran into an issue with the annotations and had no idea how to track down the issue.
不幸的是,我遇到了有关注释的问题,却不知道如何找到问题所在。 I was using the
@PageableDefault
annotation on my controller method with the @RepositoryRestController
annotation at the class level, which resulted in my Pageable
object to be null
under Spring Boot 1.4.1. 我用的是
@PageableDefault
我与控制器方法注释@RepositoryRestController
在类级别的注释,这导致了我Pageable
对象是null
条件下春小麦引导1.4.1。 If I used @Controller
, my pageable object would be populated correct. 如果使用
@Controller
,则会正确填充我的可分页对象。 This ended up being a bug DATAREST-906 in Spring Data Rest and fixed in Spring Boot 1.4.2. 最终这是Spring Data Rest中的DATAREST-906错误,并在Spring Boot 1.4.2中修复。
As a use case above what should I have done to debug this issue? 作为上面的用例,我应该怎么做才能调试此问题? Where should I have put my breakpoint to go down the rabbit hole?
我应该把断点放到哪里去?
You need to find the code that actually checks for the annotation and executes some logic based on it. 您需要找到实际检查注解并根据其执行一些逻辑的代码。 This could theoretically happen in several places.
理论上,这可以在几个地方发生。 If you search for occurrences of
WhateverAnnotation.class
in the source code you can find those places. 如果您在源代码中搜索
WhateverAnnotation.class
出现,则可以找到这些地方。 You can also put breakpoints there, if you've linked the source properly in your IDE. 如果已在IDE中正确链接了源代码,则也可以在其中放置断点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.