<tfoot id='ajiwZ'></tfoot>

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

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

      2. 如何创建作为一组杰克逊注释的注释?

        时间:2023-07-26

              <tfoot id='AYICV'></tfoot>

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

              1. <small id='AYICV'></small><noframes id='AYICV'>

                  <bdo id='AYICV'></bdo><ul id='AYICV'></ul>
                    <tbody id='AYICV'></tbody>

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

                  问题描述

                  大约一年后,我读了一篇文章,解释了如何创建一个基本上是其他注释容器的注释.这样,如果我总是在特定用例中使用相同的 5 个注解,我会创建一个包含它们的注解并改为使用它.

                  A year or so I read an article that explained how I could create an annotation that basically is a container for other annotations. This way if I always use the same 5 annotations in a specific use-case I create an annotation that contains them and use that instead.

                  很遗憾,我再也找不到这篇文章了,我很想现在就为我的 jackson 配置做这篇文章.

                  Unfortunately, I can't find the article anymore and would really like to do that right now for my jackson configuration.

                  由于我自己找不到任何相关信息,我开始质疑我的记忆力.这是可能的还是我错了?

                  Since I can't find any information on that on my own I'm beginning to question my memory. Is this possible or I am just wrong?

                  编辑

                  我想要的是这样的:

                  @Target(ElementType.METHOD)
                  @com.fasterxml.jackson.databind.annotation.JsonSerialize(using=MySerializerThatIsUsedEverywhere.class
                  @javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter(MyCustomXmlAdapter.class)
                  @SomeOtherEvaluatedByTheSerializer
                  public @interface SerializerUseCase01 {
                      public String a();
                      public int b();
                  )
                  

                  我的场景是我有一堆序列化用例,可以由具有不同配置的相同序列化程序处理.为了让一切更容易使用和更透明,我想将 jackson 配置和序列化器配置包装到一个注释中.

                  my scenario is that i have a bunch of serialization use cases that can be handled by the same serializer with different configs. To make everything easier to use and more transparent i want to wrap the jackson config and the serializer config into one annotation.

                  推荐答案

                  对于 Jackson,这可以通过 @JacksonAnnotationsInside 元注释来完成.有关更多信息,请参阅这篇文章,但其中的代码片段是:

                  For Jackson, this can be done with @JacksonAnnotationsInside meta-annotation. See this article for more, but code snippet from there is:

                  @Retention(RetentionPolicy.RUNTIME) // IMPORTANT
                  @JacksonAnnotationsInside
                  @JsonInclude(Include.NON_NULL)
                  @JsonPropertyOrder({ "id", "name" }) 
                  public @interface MyStdAnnotations
                  

                  从那时起,您可以将这种类型用于您自己的类,如下所示:

                  and from thereon you can use this type for your own classes like so:

                  @MyStdAnnotations
                  public class MyBean {
                     public String name, id;
                  }
                  

                  这篇关于如何创建作为一组杰克逊注释的注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Java 中的@interface 默认声明用法 下一篇:从 Java 注释处理器访问源代码

                  相关文章

                  最新文章

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

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

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

                    1. <tfoot id='IkLwx'></tfoot>
                        <bdo id='IkLwx'></bdo><ul id='IkLwx'></ul>