I'm trying to parse my object to XML using jackson-dataformat-xml and, when i set the root namespace and parse the file, all properties of my object in the XML gives a empty namespace xmlns="". On jackson's github docs, is advise to use woodstox instead stax XML implementation to solve this but, the behavior still exists.
This is my pojo:
@JacksonXmlRootElement(namespace = "https://www.google.com.br")
public class Cliente implements Serializable {
// Omitted
}
And my parse code:
Cliente cliente = new Cliente();
cliente.setId(new Long(1));
cliente.setNome("Tiago Cassio".toUpperCase());
cliente.setSobrenome("da Conceicao".toUpperCase());
Endereco endereco = new Endereco();
endereco.setId(new Long(1));
endereco.setLogradouro("blablabla");
endereco.setNumero("999");
endereco.setCep("99999");
endereco.setBairro("blablabla");
cliente.setEndereco(endereco);
ObjectMapper mapper = new XmlMapper();
System.out.println(mapper.writeValueAsString(cliente));
This is the XML generated:
<Cliente xmlns="https://www.google.com.br">
<id xmlns="">1</id>
<nome xmlns="">TIAGO CASSIO</nome>
<sobrenome xmlns="">DA CONCEICAO</sobrenome>
<endereco xmlns="">
<id>1</id>
<logradouro>blablabla</logradouro>
<numero>999</numero>
<cep>99999</cep>
<bairro>blablabla</bairro>
</endereco>
</Cliente>
Any idea where is the problem? My project is under a Spring boot version 1.3.0.M5. Thanks for all.