简体   繁体   English

如何调试Spring注释?

[英]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.

相关问题 如何使用注解将Spring安全性配置为在处女座上工作? - How do I configure Spring security to work on Virgo - using annotations? 如何使用注释对Spring Controller进行单元测试? - How do I unit test Spring Controller using annotations? 如何在 Spring RestTemplate 中使用 JAXB 注释? - How do I use JAXB annotations with Spring RestTemplate? 如何在Spring中使用注释定义PasswordEncoder? - How do I define a PasswordEncoder using annotations in Spring? 如何使用Spring注释将Properties文件中的值注入到现有实例(不受Spring管理)的字段中? - How do I inject a value from Properties file to a field of an existing instance (not managed by Spring) using Spring annotations? 如何在Spring / Maven项目中调试此构建失败? - How do I debug this Build Failure in my Spring/Maven project? 如何在不使用 bean 或注释的情况下手动初始化 Spring Boot 存储库? (科特林) - How do I manually initialize a Spring Boot repository without using beans or annotations? (Kotlin) 如何使用Java批注设置Spring Integration Collaborating Channel适配器? - How do I setup Spring Integration Collaborating Channel adapters with Java annotations? 如何使用注释对Spring执行基于构造函数的依赖注入? - How do I perform Constructor-based dependency injection with Spring using annotations? 如何使用Java Spring注释在MongoDB中创建完全填充的引用对象 - How do I make a fully populated reference object in MongoDB using java spring annotations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM