• <bdo id='LPvMA'></bdo><ul id='LPvMA'></ul>
    <legend id='LPvMA'><style id='LPvMA'><dir id='LPvMA'><q id='LPvMA'></q></dir></style></legend>

    <small id='LPvMA'></small><noframes id='LPvMA'>

      <tfoot id='LPvMA'></tfoot>
    1. <i id='LPvMA'><tr id='LPvMA'><dt id='LPvMA'><q id='LPvMA'><span id='LPvMA'><b id='LPvMA'><form id='LPvMA'><ins id='LPvMA'></ins><ul id='LPvMA'></ul><sub id='LPvMA'></sub></form><legend id='LPvMA'></legend><bdo id='LPvMA'><pre id='LPvMA'><center id='LPvMA'></center></pre></bdo></b><th id='LPvMA'></th></span></q></dt></tr></i><div id='LPvMA'><tfoot id='LPvMA'></tfoot><dl id='LPvMA'><fieldset id='LPvMA'></fieldset></dl></div>

        如何编写 Java 注释处理器?

        时间:2023-07-26

        <tfoot id='lY40v'></tfoot>

          <small id='lY40v'></small><noframes id='lY40v'>

          • <i id='lY40v'><tr id='lY40v'><dt id='lY40v'><q id='lY40v'><span id='lY40v'><b id='lY40v'><form id='lY40v'><ins id='lY40v'></ins><ul id='lY40v'></ul><sub id='lY40v'></sub></form><legend id='lY40v'></legend><bdo id='lY40v'><pre id='lY40v'><center id='lY40v'></center></pre></bdo></b><th id='lY40v'></th></span></q></dt></tr></i><div id='lY40v'><tfoot id='lY40v'></tfoot><dl id='lY40v'><fieldset id='lY40v'></fieldset></dl></div>
              <bdo id='lY40v'></bdo><ul id='lY40v'></ul>

                <legend id='lY40v'><style id='lY40v'><dir id='lY40v'><q id='lY40v'></q></dir></style></legend>
                  <tbody id='lY40v'></tbody>

                • 本文介绍了如何编写 Java 注释处理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我可能只是在寻找错误的方向,但我发现关于注释处理的 JSE 文档非常……稀疏.我想编写一个注释处理器来处理带注释的字符串字段和局部变量,以用计算的字符串表达式替换它们.这不应该太复杂,但我在 javax.annotation.processing 的 Javadoc 中迷失了.

                  I may be just looking in the wrong direction but I find the JSE documentation on annotation processing very ... sparse. I want to write an annotation processor which processes annotated String fields and local variables to substitute them with a computed String expression. This should not be too complicated but I'm pretty lost in the Javadoc for javax.annotation.processing.

                  我需要在编译时处理注释,因为我想修改生成的代码.它应该用计算的字符串表达式替换带注释的常量字符串表达式.

                  I need to process annotations at compile time because I want to modify the generated code. It should replace annotated constant String expressions with a computed String expression.

                  推荐答案

                  编译时注释处理器无法做到这一点.编译时注释处理器只能生成新文件(和类),它们不能修改现有类.您可以在运行时进行反射,但严格来说您不称为注释处理.此外,您将无法访问局部变量.

                  This can not be done with a compile time annotation processor. Compile time time annotation processors can only generate new files (and classes) they can not modify existing classes. You can do reflection at runtime but strictly speaking you that is not called annotation processing. Also you won't have access to local variables.

                  如果您正在研究如何编写编译时注释处理器,请查看 https://github.com/pellaton/spring-configuration-validation-processor

                  If you're looking on how to write a compile time annotation processor check out https://github.com/pellaton/spring-configuration-validation-processor

                  这篇关于如何编写 Java 注释处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:我应该将@Transactional 注释放在哪里:在接口定义或 下一篇:Spring:在属性文件中定义 @RequestMapping 值

                  相关文章

                  最新文章

                    <i id='MrIQB'><tr id='MrIQB'><dt id='MrIQB'><q id='MrIQB'><span id='MrIQB'><b id='MrIQB'><form id='MrIQB'><ins id='MrIQB'></ins><ul id='MrIQB'></ul><sub id='MrIQB'></sub></form><legend id='MrIQB'></legend><bdo id='MrIQB'><pre id='MrIQB'><center id='MrIQB'></center></pre></bdo></b><th id='MrIQB'></th></span></q></dt></tr></i><div id='MrIQB'><tfoot id='MrIQB'></tfoot><dl id='MrIQB'><fieldset id='MrIQB'></fieldset></dl></div>

                    <small id='MrIQB'></small><noframes id='MrIQB'>

                    <tfoot id='MrIQB'></tfoot>

                    <legend id='MrIQB'><style id='MrIQB'><dir id='MrIQB'><q id='MrIQB'></q></dir></style></legend>

                      • <bdo id='MrIQB'></bdo><ul id='MrIQB'></ul>