CREATE DATABASE springboot_rest_jpa;
USE springboot_rest_jpa;
CREATE TABLE blog (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(500) NOT NULL,
content VARCHAR(5000) NOT NULL
);
- Add Jackson Dataformat XML into pom.xml
- Add produces property which specifies json & xml format
- Request can be made like this:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.10.0</version>
</dependency>
@GetMapping(path="/blog", produces = { "application/json", "application/xml" })
a) http://localhost:8085/blog.xml
b) http://localhost:8085/blog.json
c) http://localhost:8085/blog
providing a key-value pair into the request header like this:
Key = Accept, value = application/xml
- JDK 1.8
- Spring Boot Starter Parent-1.5.9.RELEASE
- MySql 8.0.17