Skip to content

TonyMwangi/springboot_rest_jpa_mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

springboot rest jpa mysql

A java SringBoot REST API application with Data JPA & MySql DB.

DB creation

    
      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
      );
    
  

Get responses both in XML & Json format

  1. Add Jackson Dataformat XML into pom.xml
  2.     	
    	<dependency>
                <groupId>com.fasterxml.jackson.dataformat</groupId>
                <artifactId>jackson-dataformat-xml</artifactId>
                <version>2.10.0</version>
            </dependency>
    	
      	
  3. Add produces property which specifies json & xml format
  4.     	
    	@GetMapping(path="/blog", produces = { "application/json", "application/xml" })
    	
      	
  5. Request can be made like this:
  6.     	
    	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	
    	
      

Technolgy Used

  • JDK 1.8
  • Spring Boot Starter Parent-1.5.9.RELEASE
  • MySql 8.0.17

Preview

1. Get Request

Image description


2. Get Request with body parameter

Image description


3. Post Request

Image description


4. Put Request

Image description


5. Delete Request

Image description


6. Response in XML

Image description

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published