Spring Boot XML 사용 시 RestTemplate 주의할 점

@ZungTa · 2024-08-21 수요일 · 1 min read

build.gradle에 xml 관련 라이브러리를 추가하게되면 RestTemplate의 기본 Content-Type 설정이 application/xml로 바뀌게 된다.

RestTemplate을 사용할 때 Content-Type을 명시해서 사용했다면 문제가 없지만 기본 값으로 사용했다면 문제가 생길 수 있다.

Content-Type 기본 값이 application/json에서 application/xml로 바뀌기 때문이다.

RestTemplate.HttpEntityRequestCallback.doWithRequest에서 messageConverter의 값이 application/xml로 바뀐 것을 확인할 수 있다.

rest-tamplate-do-with-request

rest-tamplate-do-with-request

xml 라이브러리 추가 전

before-add-xml-library

before-add-xml-library

xml 라이브러리 추가 후

after-add-xml-library

after-add-xml-library

References

@ZungTa
I'm a backend developer
© ZungTa Devlog, Built with Gatsby