Spring XML Marshalling with XOM
<dependency>
<groupId>com.itelg.spring</groupId>
<artifactId>spring-xom-marshaller</artifactId>
<version>1.3.0</version>
</dependency>
@Autowire XomMarshaller for further use in MarshallingHttpMessageConverter or MarshallingMessageConverter.
@SpringBootApplication
@EnableXomMarshaller
public class Application
{
@Autowired
private XomMarshaller xomMarshaller;
public static void main(String[] args) throws Exception
{
SpringApplication.run(Application.class, args);
}
}
@Component
public class IntegerWriter extends AbstractWriter<Integer>
{
@Override
protected Element doWrite(Integer integer)
{
Element rootElement = new Element("integer");
Element valueElement = new Element("value");
valueElement.appendChild(integer.toString());
rootElement.appendChild(valueElement);
return rootElement;
}
}
mvn clean package
mvn clean deploy