I want to add a custom attribute to the start of my xml tag using java, tried using serializer & other solutions but did not work.
*Code* :
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
@JacksonXmlRootElement(localName = "TestClass")
public class TestClass{
@JacksonXmlProperty(localName = "TestVariable")
private String testVariable;
}
I am expecting the below output where i have mentioned custom attribute in the start tag:
<TestClass>
<TestVariable unit="km">100</TestVariable>
</TestClass>
custom attribute : unit="km"