【问题标题】:Spring XML use anotations in beansSpring XML 在 bean 中使用注解
【发布时间】:2020-01-20 09:00:36
【问题描述】:

当我编译我的 XML 时,我需要使用以下注释生成这 2 个属性:

@JsonProperty("application_id") 私有字符串 foo;

@JsonProperty("application_no")
private String bar;

如何标记我的 XML bean 以便在我的 POJO 中获得这些注释:

 <bean class="com.foo.bar.Test">
        <property name="foo" type="String"/>
        <property name="bar" type="String"/>
    </bean>

我需要通过 XML Spring 注入它们,而不接触 Java,

【问题讨论】:

  • 这与Spring无关;都是关于杰克逊的。您可能需要查看 Jackson mixin。
  • 你的问题没有什么意义。我建议您对其进行编辑,以提供有关问题所在以及您试图实现的目标的更多信息。

标签: java spring annotations


【解决方案1】:
 <property name="defaults" type="java.util.Set&lt;String>">
            <annotations>@com.fasterxml.jackson.annotation.JsonProperty("default")</annotations>
        </property>

【讨论】:

    猜你喜欢
    • 2015-09-20
    • 2020-03-21
    • 1970-01-01
    • 2017-02-18
    • 2016-10-31
    • 2012-08-06
    • 1970-01-01
    • 1970-01-01
    • 2013-04-27
    相关资源
    最近更新 更多